Ubuntu – Can cron write job output to a log *by default* (instead of mail)

cronemaillog-filesUbuntu

We all know the right way to handle output from cron jobs is to redirect it to a file:

0 * * * * /bin/date >> /var/log/date.log 2>&1

However, sometimes admins are lazy, forgetful, or ignorant and don't put in those redirects; in this case the output of the job gets mailed to $MAILTO or the owning user or root. On some of the boxes I manage, mail is disabled, so this output goes into a black hole. What I'm wondering is, is there any way to tell cron to take any job output and instead of mailing it, throw it into a catch-all log file somewhere? I'm using Ubuntu (8.04 but migrating to 9.04). There's a hint of such a solution in this random Google result, but I think the OP might have been confused about cron output vs. the output of cron jobs.

I'm open to solutions that involve a bit of scripting or hacking, but ideally this would be a config bit I could set somewhere. I don't see any hints in man cron. Thanks!

Best Answer

For cronie cron (which is recommended for example by Gentoo Handbook), there is "-s" argument to cron call, which sends the job output to the system log using syslog.

Related Topic