Title: Better logging for cronjob output

Posted by Stefan Lasiewski on Server Fault See other posts from Server Fault or by Stefan Lasiewski
Published on 2010-04-30T16:53:39Z Indexed on 2010/04/30 16:59 UTC
Read the original article Hit count: 185

Filed under:
|
|
|
|

I am looking for a better way to log cronjobs. Most cronjobs tend to spam email or the console, get ignored, or create yet another logfile.

In this case, I have a Nagios NSCA script which sends data to a central Nagios sever. This send_nsca script also prints a single status line to STDOUT, indicating success or failure.

0 * * * * root    /usr/local/nagios/sbin/nsca_check_disk

This emails the following message to root@localhost, which is then forwarded to my team of sysadmins. Spam.

forwarded nsca_check_disk: 1 data packet(s) sent to host successfully.

I'm looking for a log method which:

  1. Doesn't spam the messages to email or the console
  2. Don't create yet another krufty logfile which requires cleanup months or years later.
  3. Capture the log information somewhere, so it can be viewed later if desired.
  4. Works on most unixes
  5. Fits into an existing log infrastructure.
  6. Uses common syslog conventions like 'facility'
  7. Some of these are third party scripts, and don't always do logging internally.

© Server Fault or respective owner

Related posts about cron

Related posts about logging