多个crontab作业,但只有其中一个不应发送电子邮件

时间:2014-01-10 02:29:45

标签: linux email unix crontab

我知道crontab作业会将作业的输出通过电子邮件发送给用户。在我的crontab文件中,我有多个工作,如:

10 21 * * * test1.sh
13 21 * * * test2.sh
0 * * * * test3.sh

我不想收到test3.sh的电子邮件。下面的代码有效吗?我想确保只为最后一份工作我不会收到电子邮件。

10 21 * * * test1.sh
13 21 * * * test2.sh
MAILTO=""
0 * * * * test3.sh

1 个答案:

答案 0 :(得分:4)

请参阅http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/

您可以使用类似

的内容
0 * * * * test3.sh >/dev/null 2>&1

没有输出 - >没有邮件发送。