Chinaunix首页 | 论坛 | 博客
  • 博客访问: 547187
  • 博文数量: 102
  • 博客积分: 950
  • 博客等级: 准尉
  • 技术积分: 1094
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-28 16:07
文章分类

全部博文(102)

文章存档

2020年(2)

2016年(5)

2015年(15)

2014年(25)

2013年(18)

2012年(19)

2011年(18)

我的朋友

分类: LINUX

2012-03-28 15:32:20

只要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) |
0

上一篇:Python基础知识

下一篇:awk 实用技巧

给主人留下些什么吧!~~