15

I'm running an Ubuntu 12.04, I've configured "ssmtp" with my gmail account and now I'm getting every hour an email with a report, this is an example:

From: root <my@gmail.com> Date: 2012/8/13 Subject: Cron <root@one> [
-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

Some more info:

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

More...

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

More...

$ 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

# m h 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 )
#

I've commented the line 17 * * * * root cd / && run-parts --report /etc/cron.hourly, but the email still arriving.

14

Just add below to /etc/crontab

MAILTO=""

to stop crontab from sending email totally edit /etc/sysconfig/crond and add this CRONDARGS='-m off'.
Save and restart crond.

|improve this answer|||||
  • It appears this line has to be added to every crontab file wanted silenced, (atleast from my testing). also beware that user crons live elsewhere: serverfault.com/a/325344/210994 – ThorSummoner Aug 28 '15 at 21:32
  • @ThorSummoner When mentioning "...every crontab file..." is that in the crontab itself, or in the script, underneath the shebang line? – 3kstc May 12 '16 at 22:36
8

When cron starts a process, it captures any output that reaches stdout and stderr, and sends that in an email. To prevent these emails, you can re-direct the stdout and stderr, either to a logfile that you monitor, or /dev/null, if you don't care.

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly 2>&1 > /dev/null
|improve this answer|||||
  • Hi! Thanks for answer me so quickly! I've found this issue that I think is causing the problem: bugs.launchpad.net/ubuntu/+source/php5/+bug/876387 So, until the problem is resolved, I'm going to apply your solution! Thanks again! nonox – user83162 Aug 13 '12 at 20:47
  • I like this answer because it can disable mails for a specific job, rather than the MAILTO="" which would disable all cron mail. – mike Jan 27 '15 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.