crontab定时任务发邮件的问题

在用 crontab -e 命令创建定时任务后,发现定时任务中的发邮件并未执行。

通过上网查询,可以看crontab的日志。命令如下:

1
tail /var/log/cron

执行结果如下图:

发现发送邮件报错为 mailed 284 bytes of output but got status 0x004b#012


通过查询资料,最终解决方案如下

文字说明:修改 /etc/postfix/main.cf文件,将其中的 inet_interfaces 设置为all。

操作:

执行命令, 修改文件内容

1
vim /etc/postfix/main.cf

最终可以解决,但并不知道原理,不知道会不会影响系统安全性。

参考执行

1
nohup  python3 -u /root/services/ISL.py  >> /root/services/ISL.log 2>&1  &