email notification if job is killed/dies


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting email notification if job is killed/dies
# 1  
Old 05-14-2002
Question 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
# 2  
Old 05-14-2002
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 Smilie
# 3  
Old 05-15-2002
Quote:
Originally posted by usfrog
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 Smilie
thanks buddy, Smilie

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 !!!Smilie

thanks again
jacob
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Email notification error on Solaris

Hi, I am getting error below when testing email. is there a way I can configure email on Solaris? SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise echo "hello" | sendmail -v abcd WARNING: local host name (-s) is not qualified; see cf/README: WHO AM I? abcd... Connecting... (1 Reply)
Discussion started by: roshanbi
1 Replies

2. Shell Programming and Scripting

Email Notification

Hi All, I need write a linux script which emails each record to the employee manager email-id which will be specified inside the file. Each employee can have a different manager too.. file contain 200 to 300 records Employee ID, Employee Name, Employee Email-ID, Manager, Manager... (4 Replies)
Discussion started by: tradingspecial
4 Replies

3. Shell Programming and Scripting

Notification after job is done

Hello everyone, I have a server in another country, so I would like to run a notification sound, that I can hear in my computer after a job is finished, I found so many commands, like: COMMAND HERE spd-say 'Done' But I cannot hear any sound, the command line does NOT return any error,... (6 Replies)
Discussion started by: Abu Rayane
6 Replies

4. AIX

Cron Job notification email

Hi, I'm fairly new to Aix and am looking for some help on the following. I have setup a cron job under root and want it to send the email once it's run to an external email address. I can get it to send the output in an email to me by using mail on the end of the crontab entry. But I would... (1 Reply)
Discussion started by: elmesy
1 Replies

5. Solaris

Cron Job -- auto start process when it dies

I would like to setup a Cron job to check weather X process is running or not. if it is not running then start that X process with a log message.... can any one help writing a script? thanks (3 Replies)
Discussion started by: chandravadrevu
3 Replies

6. Shell Programming and Scripting

Crontab change and email notification

Hey guys Just need some help with crontab.Iam looking for a script that will alert particular user about its change through sendmail.We are using bash here. --CoolKid (3 Replies)
Discussion started by: coolkid
3 Replies

7. Programming

Status of child job after parent is killed

Hi, I have a requirement. Scenario: A parent job invokes a child job and gets killed. The child becomes orphan and gets attached to init. Child job is removed from the pid table as soon as it gets completed. Requirement is i need the status of the child job even after the parent job is... (7 Replies)
Discussion started by: anjul_thegreat
7 Replies

8. UNIX for Dummies Questions & Answers

background job finished notification

In my last job someone gave me the command to put in my .profile that let me know when a job I had running in the background finished. It was a word about 5 char long. I can't remember it! (4 Replies)
Discussion started by: nkeller
4 Replies

9. UNIX for Dummies Questions & Answers

How to add email notification in scripts?

Hi. I want to add email notification so when the my script finishes it sends out an email of the results to our team. If there are errors the subject on the email should say there were errors. If any having idea/sample scripts pls share with me. (2 Replies)
Discussion started by: redlotus72
2 Replies

10. Post Here to Contact Site Administrators and Moderators

Why am I not recieving email notification?

I have been a member for almost a year now. I have always recieved email notifications when I select "subcribe to this thread" at the bottom of posts that I reply to. However, over the last month or so, I have not been recieving email notification of replys to posts I respond to. I have... (6 Replies)
Discussion started by: Kelam_Magnus
6 Replies
Login or Register to Ask a Question