email notification if job is killed/dies

hi folks,

anybody there with suggestions on how to have an email sent to an address (if a certain job (jobA) ever dies. the concern is over the trigerring of sending the email (not the actual sending of the email)

  1. is it possible for the job in question, jobA, itself do such a thing (unlikely perhaps, but if possible would be the most elegant)

  2. we could set up another job (jobB) to monitor jobA and have it email us if it detects jobA has died. that however raises the question of what happens if jobB itself is killed/dies before jobA.

any guidance will be greatly appreciated

thanks
jacob

Hi Jacob,

Try something like:

numberOfProcesses=`ps -ef|grep myProcessName|grep -v grep|wc -l`
if [ $numberOfProcesses = 0 ]
then
( echo "From: missingProcesses@yourHostName"
echo "To: yourAddress@wherever.com"
echo "Subject: myProcessName is not running"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "The process is not running"
echo " "
) | /usr/lib/sendmail -i -t
fi

And schedule that little script as a cron.
Hope this helps :confused:

thanks buddy, :slight_smile:

that sure is a good pointer in the right direction. i will modify it a bit because our admin doesn't give us cron rights on our system !!!:mad:

thanks again
jacob