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: 211
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:
- Doesn't spam the messages to email or the console
- Don't create yet another krufty logfile which requires cleanup months or years later.
- Capture the log information somewhere, so it can be viewed later if desired.
- Works on most unixes
- Fits into an existing log infrastructure.
- Uses common syslog conventions like 'facility'
- Some of these are third party scripts, and don't always do logging internally.
© Server Fault or respective owner