up vote 4 down vote favorite
1
share [g+] share [fb]

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)

btw- i'm using debian

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

link|improve this question

75% accept rate
feedback

2 Answers

You can send the output of cron to a seperate log facility, add the following to your /etc/syslog.conf

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

Remember to add /var/log/cron to you /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
}
link|improve this answer
Thank you for the input. I added cron.* /var/log/cron and restarted cron but it continues to dump the messages into /var/log/syslog while leaving /var/log/cron empty. not sure why it's not doing anything – user7321 Jun 25 '09 at 3:49
oh man, epic failure on my part. I was editing syslog.conf and restarting cron!! No wonder it wouldn't work.. I should have been restarting syslog =) – user7321 Jun 25 '09 at 3:56
feedback
up vote 1 down vote accepted

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.
link|improve this answer
serverfault is telling me that I need to wait 48 hrs before accepting my own answer soo... gg =) – user7321 Jun 25 '09 at 4:12
feedback

Your Answer

 
or
required, but never shown

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