我已经为 root 用户设置了 cronjob。但是,当 cron 失败时,我应该会收到一封来自 cronjob 的电子邮件,因为我在 /etc/crontab 中设置了 MAILTO:
MAILTO=my@email.com
Run Code Online (Sandbox Code Playgroud)
我已经使用安装了 mailx
yum install mailx
Run Code Online (Sandbox Code Playgroud)
但是当我查看 cron 日志时,我得到以下几行:
Feb 23 14:13:01 internal crond[6858]: (root) CMD (/var/www/vded/build/bin/sync.sh)
Feb 23 14:13:01 internal crond[6857]: (root) MAIL (mailed 79 bytes of output but got status 0x0001 )
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
更新 :
我在邮件日志中收到此错误:
Feb 23 16:06:01 internal sendmail[7210]: o1NG61cd007210: from=root, size=425, class=0, nrcpts=1, msgid=<201002231606.o1NG61cd007210@internal.fff.com>, relay=root@localhost
Feb 23 16:06:01 internal sendmail[7211]: o1NG61hT007211: from=<root@internal.fff.com>, size=732, class=0, nrcpts=1, msgid=<201002231606.o1NG61cd007210@internal.fff.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Feb 23 16:06:01 internal sendmail[7210]: o1NG61cd007210: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30425, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o1NG61hT007211 Message accepted for delivery)
Feb 23 16:06:01 internal sendmail[7212]: o1NG61hT007211: to=<root@internal.fff.com>, ctladdr=<root@internal.fff.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30972, dsn=2.0.0, stat=Sent
Run Code Online (Sandbox Code Playgroud)
internal.fff.com 是服务器的名称。
更新 :
所以事实上,如果我把它MAILTO=my@email.com
作为我的 crontab 的第一行(使用crontab -e
)它正在工作。
为什么通过设置MAILTO
in不起作用/etc/crontab
?
谢谢
所以回答我的问题:
yum install mailx
yum install sendmail
MAILTO
线进入crontab的使用crontab -e
:MAILTO=my@email.com
而不是/etc/crontab
归档时间: |
|
查看次数: |
35093 次 |
最近记录: |