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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vague cron question

Status
Not open for further replies.

sbrews

Technical User
Jun 11, 2003
413
US
I have some developers that run a bunch of cron jobs. Intermittantly, one or 2 of the cron jobs will fail - IE it doesnt run and there are no other errors to indicate why.

Short of moving away from cron to something else, IE Autosys,
they are asking if there are any tools that will monitor cron for jobs run/not run/run but fail, etc. I have been searcing around the net but have come up empty handed. Does anyone know of something that will monitor cron and report on jobs run/not run?

scott
 
If it runs on the command line but not from cron it is almost always (five 9s) an environmental problem.
 
The jobs DO run from the command line and 99% of the time, they also run from cron. Its that 1% that they dont run and with no error/output of any kind - other than the missing reports they should have generated.
 
Yes you can do this:

Example

Code:
0 7 * * * /job_to_be_run.sh 1>/log1.txt 2>/log2.txt

then you can monitor those two logs and see whether the job ran (date will be modified) or not (assuming the job is outputing something)

and if you can modify the job it self to examine the exit code of the command to be run inside the script like for example:

Code:
find /DB_bkup \
     -print > /tmp/daily_backup.list

cat /tmp/daily_backup.list | backup -iqf/dev/rmt0.1
#
if [ $? -eq 0 ]
then
  echo "Backup ended   at   `date` successfully." >> /tmp/msg.txt

else
  echo "Backup ended   at   `date` un-successfully." >> /tmp/msg.txt
fi

Regards,
Khalid
 
Have you taken a look at /var/adm/cron/log. This should tell you if the jobs are being submitted or not.
 
the /var/adm/cron/log file does indeed tell if the job was submitted. Now to come up with something to actively monitor this file (that doesnt run from cron, since cron seems to periodically not work) and check for those jobs.
 
Once you see a job fail in the cron log (I can't find one on my systems) you can set up a cron job (haha) to scan the log every few minutes / hours and output any 'failed' jobs to another log file and then mail you to let you know what failed.
Offers of suitable scripts apply here please.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top