简体   繁体   English

从crontab发送邮件时,电子邮件正文内容将被删除

[英]email body content gets removed when mail sent from crontab

I have following command in Ubuntu Linux, 我在Ubuntu Linux中有以下命令,

mysql -u root -p"password" "dbname" -e 'select count(*) User_Count from "tableName"' | mysql -u root -p“密码”“ dbname” -e'从“ tableName”中选择count(*)User_Count' mail 邮件

-s 'Count' "email_id" -s'计数'“ email_id”

When this command is executed from command line it send mail with subject and query output as message body 从命令行执行此命令时,它将发送带有主题和查询输出的邮件作为邮件正文

However if I schedule the same command through crontab - I get email only with subject and message body is empty 但是,如果我通过crontab安排相同的命令-我只会收到主题和邮件正文为空的电子邮件

That's probably an indicator that mysql is failing to run as specified. 这可能表明mysql无法按照指定的方式运行。

Redirect standard error when you run the command, and you'll at least get an e-mail with the error message telling you what you're missing: 运行命令时重定向标准错误,至少会收到一封电子邮件,其中包含错误消息,告诉您所缺少的内容:

mysql 2>&1 -u root -p -e 'select count(*) User_Count from ' | mail -s 'Count' "email_id"

Also, make sure the directory where mysql resides is either in the PATH, or you specify it manually on the command line. 另外,确保mysql所在的目录位于PATH中,或者您在命令行上手动指定它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果从php mail()函数发送的电子邮件返回,它在linux中的位置? - If an email sent from php mail() function returns, where is it located in linux? 使用crontab发送邮件时没有附件 - No attachment when using crontab to send mail 使用 mail 命令发送电子邮件时指定发件人用户 - Specify the from user when sending email using the mail command Linux Shell 脚本用于提取已发送电子邮件的数据并将其发送回管理员 - Linux Shell Script to extract data of email sent and mail back to admin 使用crontab job发送邮件,email文本转为附件ATT00001.bin - Use crontab job send mail, The email text turns to an attached file which named ATT00001.bin 使用 crontab 发送电子邮件时如何更改主题? - How to change the subject when sending email using crontab? PHPMailer和SMTP:从远程服务器发送邮件时永远不会显示邮件,在本地计算机上可以正常工作 - PHPMailer and SMTP: Mail never shows up when sent from remote server, works fine on local machine 如何访问某些电子邮件,并打印特定邮件的邮件正文? - How to access some email, and print a specific mail's message body? 从Crontab执行时结果不同 - Different result when executed from Crontab 从crontab运行时找不到Sqlplus命令 - Sqlplus command not found when running from crontab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM