Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to monitor that cron jobs are being executed

Status
Not open for further replies.
Jan 28, 2009
1
0
0
US
I recently had a mini-scare at work here where some of my cron jobs were not executing due to password expiration rules. I was asked if there would be a way to monitor that the cron for various accounts are actually working. I have been thinking of ways to do this and thought I'd ask the experts here for any suggestions.

My idea:
-- Add a line to the crontab that would echo the account name into a flag file in a directory. I would set this up for every account I want to monitor.

-- Write a script that checks the flag file directory and the "age" of each of the flag files (or if they even exist). If the age is over a day or so old or the file doesn't exist then alert me via email.

What do you guys think?
 

Create an execution log and monitor those:
Code:
# Example crontab entry:
30 01 * * 0-6 $HOME/scripts/dba/hotbackup.ksh ORCL1 > /orabackup/log/backORCL1_`date +%Y%m%d`.log 2>&1
[3eyes]



----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Try
Code:
grep -q Failed /var/adm/cron/log && echo "A cron job has failed" | mail -s "cron job failure" me@myserver
Of course you would have to reset the log file after every failure and the script could be nicer but you get the idea.

On the internet no one knows you're a dog

Columb Healy
 
Sorry - addendum
The /var/adm/cron/log file exists on AIX but not on RedHat Linux so it looks like this method is dependant on your flavour of Unix/Linux

On the internet no one knows you're a dog

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top