如何从Cron (每小时)停止电子邮件报告

我正在运行Ubuntu 12.04,我已经使用我的gmail帐户配置了“ssmtp”,现在我每小时收到一封带有报告的电子邮件,这是一个例子:

From: root  Date: 2012/8/13 Subject: Cron  [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete To: root Failed loading /usr/lib/php5/20090626/xdebug.so: /usr/lib/php5/20090626/xdebug.so: cannot open shared object file: No such file or directory 

更多信息:

 $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=12.04 DISTRIB_CODENAME=precise DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS" 

更多…

 $ sudo crontab -l -u root no crontab for root 

更多…

 $ nano /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # mh dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # 

我已经评论了17 * * * * root cd / && run-parts --report /etc/cron.hourly ,但邮件仍然到达。

只需在/etc/crontab下面添加

 MAILTO="" 

阻止crontab发送电子邮件完全编辑/etc/sysconfig/crond并添加此CRONDARGS='-m off'
保存并重启crond。

当cron启动进程时,它会捕获到达stdout和stderr的任何输出,并将其发送到电子邮件中。 要阻止这些电子邮件,您可以将stdout和stderr重定向到您监视的日志文件,或者/ dev / null,如果您不关心。

 17 * * * * root cd / && run-parts --report /etc/cron.hourly 2>&1 > /dev/null