How can I prevent cron from filling up my syslog?

I have a script which needs to be executed each minute. The problem is that cron is logging to /var/log/syslog each time it executes. I end up seeing something like this repeated over and over in /var/log/syslog:

Jun 25 00:56:01 myhostname /USR/SBIN/CRON[1144]: (root) CMD (php /path/to/script.php > /dev/null)

I'm using Debian.

My questions is: Is there any way I can tell cron not write this information to syslog every time?


Solution 1:

You can send the output of cron to a separate log facility add the following to your /etc/syslog.conf file:

# Log cron stuff
cron.*                                                  /var/log/cron

Remember to add /var/log/cron to your /etc/logrotate.d/syslog to ensure it gets rotated, eg

# /etc/logrotate.d/syslog
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

Solution 2:

Ok,

The solution to my question was:

change

*.*;auth,authpriv.none     -/var/log/syslog

to

*.*;cron,auth,authpriv.none     -/var/log/syslog

within /etc/syslog.conf and then restart syslog

I also have cron being sent to /var/log/cron.log as suggested by Dave Cheney and stuck a logrotate on it. My fix with Daves suggestion is optimal for my situation because:

  1. it keeps /var/log/syslog from being cluttered with cron messages
  2. I still get cron messages (which is nice for troubleshooting)
  3. logrotate keeps /var/log/cron.log from going too large.