只要crontab里的脚本有输出信息就会调用mail发邮件
解决办法:
1. crontab里每个脚本都 跟着 1>/dev/null 2>&1
或 1>/var/log/xxxx.log 2>&1
2. 脚本不让有任何输出,包括错误信息
3. man 5 crontab
设置全局变量
MAILTO=""
If MAILTO is defined (and non-empty), mail is sent to the user
so named. If MAILTO is defined but empty (MAILTO=""), no mail will be sent. Otherwise mail is sent to the
owner of the crontab.
还有其他办法吗
我想。。。,重新编译cron ,不现实
改环境变量MAIL=/dev/null ??
=====================
注意crontab里直接写命令时,特殊字符需要转义 % 转换成\%
/bin/tar -zcvf /data/chefbackup/chef-repo_`date +\%F`.tar.gz /root/chef-repo/
crontab里全局变量设置
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
SHELL=/bin/bash
阅读(1449) | 评论(0) | 转发(0) |