I have the following job in my crontab:

0 */4 * * * /usr/bin/mysqldump -u root -p'PASSWORD' --all-databases | /bin/gzip -9 > /home/USER/_mysql_backup/`date "+\%F--\%H-\%M"`.databases.sql.gz ; rm -f /home/USER/_mysql_backup/`date '+\%F' --date '1 week ago'`.databases.sql.gz >/dev/null 2>&1

The problem is that it's filling up my syslog. I thought adding >/dev/null 2>&1 would prevent the job from being logged, but do I also need to add it for the previous command before the ; ?

  • You are only redirecting the output of rm -f [...] to /dev/null. What do you see in the log?
    – Panki
    Nov 4, 2019 at 12:58
  • I see this CRON[22446]: (CRON) info (No MTA installed, discarding output) CRON[22471]: (user) CMD (/usr/bin/mysqldump -u root -p'PASSWORD' --all-databases | /bin/gzip -9 > /home/USER/_mysql_backup/date "+%F--%H-%M".databases.sql.gz ; rm -f /home/USER/_mysql_backup/date '+%F' --date '1 week ago'.databases.sql.gz >/dev/null 2>&1) Nov 4, 2019 at 13:01
  • so basically the whole command Nov 4, 2019 at 13:03
  • 1
    This has nothing to do with the actual output of the command. cron simply logs what it executes. Your question should read "how do I stop cron from logging executed commands?"
    – Panki
    Nov 4, 2019 at 13:20

1 Answer 1


If the command in the crontab writes anything to stdout, then cron will take that output and try to mail it to you. Apparently you have no MTA installed, so cron fails to send a mail message and logs that failure to the log file.

If you want to see what the cron job is writing to its stdout, then you have to install an MTA: cron will mail you that output and will presumably not log anything since the sending of the mail will succeed.

If you don't want to see the output, then redirect it to /dev/null. I would still set up an MTA though, so that cron will be happy even when some cron job produces output unexpectedly.

The crond(8) manpage describes the details.

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.