MAIL (mailed 317 bytes of output but got status 0x004b#012)

当Cron执行命令出错时,默认会发送邮件给cron任务的所有者.当然,发送邮件时也可能会出错.我就遇到了如题所示的错误.

我使用的机器环境为Centos7.它默认会使用Postfix来发送邮件.

#tail /var/log/cron
Feb 24 16:37:16 iZbp16mm6oot8Z CROND[20862]: (root) MAIL (mailed 317 bytes of output but got status 0x004b#012)
Feb 24 16:37:21 iZbp16mm6oot8Z CROND[20861]: (root) MAIL (mailed 317 bytes of output but got status 0x004b#012)
Feb 24 16:37:26 iZbp16mm6oot8Z CROND[20860]: (root) MAIL (mailed 317 bytes of output but got status 0x004b#012)
Feb 24 16:37:31 iZbp16mm6oot8Z CROND[20859]: (root) MAIL (mailed 317 bytes of output but got status 0x004b#012)
Feb 24 16:37:36 iZbp16mm6oot8Z CROND[20858]: (root) MAIL (mailed 317 bytes of output but got status 0x004b#012)

#cat /var/log/maillog

Feb 24 16:36:06 iZbp16mm6oot8Z postfix/sendmail[20327]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:11 iZbp16mm6oot8Z postfix/sendmail[20386]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:16 iZbp16mm6oot8Z postfix/sendmail[20434]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:21 iZbp16mm6oot8Z postfix/sendmail[20481]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:26 iZbp16mm6oot8Z postfix/sendmail[20534]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:31 iZbp16mm6oot8Z postfix/sendmail[20570]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:36 iZbp16mm6oot8Z postfix/sendmail[20614]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:41 iZbp16mm6oot8Z postfix/sendmail[20660]: fatal: parameter inet_interfaces: no local interface found for ::1
Feb 24 16:36:46 iZbp16mm6oot8Z postfix/sendmail[20711]: fatal: parameter inet_interfaces: no local interface found for ::1


vi /etc/postfix/main.cf

发现配置为:

inet_interfaces = localhost

inet_protocols = all

改成:

inet_interfaces = all

inet_protocols = all


重新启动

service postfix start

==========================================================

这个其实是postfix的配置问题,是计划任务在执行完之后会通过postfix发邮件给执行完的用户邮箱,现在发不出去导致的,修改下配置就行了,但是与本次错误无关。

也可以设置下定时器执行后不发邮件

# crontab -e
MAILTO="" #设置MAILTO参数为空

*/1 * * * * curl http://dr.host.com/cronTab/queryCurrentBill
3 4 * * * curl http://dr.host.com/cronTab/yesterDayOrders


* * * * * curl http://dr.host.com/cronTab/queryLastMonthOrder
* * * * * sleep 5; curl http://dr.host.com/cronTab/queryLastMonthOrder
* * * * * sleep 10; curl http://dr.host.com/cronTab/queryLastMonthOrder
* * * * * sleep 15; curl http://dr.host.com/cronTab/queryLastMonthOrder
* * * * * sleep 20; curl http://dr.host.com/cronTab/queryLastMonthOrder
* * * * * sleep 25; curl http://dr.host.com/cronTab/queryLastMonthOrder

这样就再也不会发邮件了。。。。。。当然也不会有那个错误了。

原文地址:https://www.cnblogs.com/yuzhould/p/14442395.html