On my small Debian squeeze web server, I have syslog-ng installed (not syslogd, like in this question). Generally, my logs are nice and quiet, with
-- MARK --
lines. My /var/log/syslog
, however, is littered with this
Sep 23 23:09:01 bookchin /USR/SBIN/CRON[24885]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete > /dev/null)
Sep 23 23:09:01 bookchin /USR/SBIN/CRON[24886]: (root) CMD ( [ -d /var/lib/php4 ] && find /var/lib/php4/ -type f -cmin +$(/usr/lib/php4/maxlifetime) -print0 | xargs -r -0 rm > /dev/null)
Sep 23 23:17:01 bookchin /USR/SBIN/CRON[24910]: (root) CMD ( cd / && run-parts /etc/cron.hourly)
kind of garbage. What's the clean way to avoid it (again, with syslog-ng)?
For syslog-ng it's slightly different than regular syslog: You need to add cron to the filter associated with
/var/log/syslog
. In/etc/syslog-ng/syslog-ng.conf
, replace this:with:
and you're done.
Another option is preventing cron from logging anything except errors:
change
/etc/default/cron
:By default the EXTRA_OPTS line is ""
Addendum:
Someone incorrectly edited this answer to make it seem as if
-L 0
would prevent cron from logging "altogether." This is incorrect. Note the description of0
in the text i posted:Or just use 4:
The OP wanted to avoid the log message every minute for the start of a cron job. Logging errors only or errors and non-zero exit statuses is a good option.