0

There is a cron job that is set which runs throughout most of the day, sometimes the job gets stuck and I would like to set a time or check on it which let's me know if it has been stuck for more than 20 minutes, I wanted to get ideas on how I can do this. At the end I would love to have it email us if it indeed has taken more than 20 minutes. Here is my crontab entry:

00 07 * * * /u01/home/oracle/sysadm/run_trans_push.sh > /u01/home/oracle/trc/run_trans_push.sh_`date +\%b_\%d`.trc 2>&1

This creates a trace file also.

1
  • Any suggestions are much appreciated. Dec 5, 2014 at 14:17

1 Answer 1

1

You can try the following: create a file before the job starts and remove it, when it finished. 20 minutes after the job starts check if the file exists. If so then send a notification

00 07 * * * touch /tmp/run_trans_push.started; /u01/home/oracle/sysadm/run_trans_push.sh > /u01/home/oracle/trc/run_trans_push.sh_`date +\%b_\%d`.trc 2>&1; rm -f /tmp/run_trans_push.started
20 07 * * * if [ -f /tmp/run_trans_push.started ]; then echo "run_trans_push still running"; fi

As fas as I know cron sends a mail to the user of the cron job, if there is an output. So I think doing an echo is sufficient. But of course you can send a mail, e.g.:

mailx -s 'run_trans_push still running' oracle </dev/null

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .