Re: Detecting failing cron jobs



In news:1177828761.136128.91150@xxxxxxxxxxxxxxxxxxxxxxxxxxx,
Terminator <manidevarajan@xxxxxxxxx> wrote:

I have 10+ cron jobs running to do various check and alert if some
condition detected. But once in a while cron job itself doesnt
complete successfully due to "cant open a log file" or so. What would
be ideal way to find some cron job didnt go thru successfully.

Should i write one more cronjob to test all other cron jobs, and
alert even if one of them fails.

In general, without knowing the exact nature of your crontab entries, you
might wish to append the following (using a semi-colon) after each crontab
entry of interest:

if [ $? -ne 0 ]; then echo "cron job failed"; fi

This will cause crond to send an email with the subject line being the cron
job which failed.

.



Relevant Pages

  • Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up)
    ... I want to run a cron job in /etc/crontab that runs (ifconfig em0 down; ... The crontab entries are passed as commands to /bin/sh, ... Then you can also use whatever you prefer to write the scripts, ...
    (freebsd-questions)
  • Cron question
    ... We have an odd problem where a cron job ... Its on a daily schedule, and it creates a log file ... so we know exactly when it does or doesnt run. ...
    (comp.unix.admin)
  • Cron question
    ... We have an odd problem where a cron job ... Its on a daily schedule, and it creates a log file ... so we know exactly when it does or doesnt run. ...
    (comp.unix.questions)
  • Re: Cron question
    ... > We have an odd problem where a cron job ... > Its on a daily schedule, and it creates a log file ... > so we know exactly when it does or doesnt run. ... Also check that cron is still running. ...
    (comp.unix.admin)
  • Re: Cron question
    ... > We have an odd problem where a cron job ... > Its on a daily schedule, and it creates a log file ... > so we know exactly when it does or doesnt run. ...
    (comp.unix.questions)