Stop cron from cluttering syslog

Every time a cron job is executed, an entry will be added to syslog, no matter whether the job succeeded or not. I have a couple of crons that run every minute, so syslog gets awfully cluttered with useless lines. Adding > /dev/null or > /dev/null 2>&1 to the job commands doesn’t help.

Fortunately cron logging can be configured, in /etc/default/cron. Log levels are explained in that file:

# Or, to log standard messages, plus jobs with exit status != 0:
# For quick reference, the currently available log levels are:
#   0   no logging (errors are logged regardless)
#   1   log start of jobs
#   2   log end of jobs
#   4   log jobs with exit status != 0
#   8   log the process identifier of child process (in all logs)

The default is to log the start of every job. I uncommented the last line and set it to EXTRA_OPTS="-L 0"

Then, restart the cron daemon:

/etc/init.d/cron restart

Leave a Reply

Your email address will not be published. Required fields are marked *

This form collects your name, email address and content so that we can keep track of the comments placed on the website. Check our privacy policy for more info on where, how and why we store your data.