nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Killing of a process and send a mail if the process doesnot come up within 2 minutes

This is a discussion on Killing of a process and send a mail if the process doesnot come up within 2 minutes within the Shell scripting forums, part of the Development/Scripting category; Hi Friends, I have a problem here and i need someone to solve this. Let us consider there are two ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-09-2008, 06:27 PM
Junior Member
User
 
Join Date: Feb 2008
My distro: Debian
Posts: 1
Rep Power: 0
Prince89 is on a distinguished road
Default Killing of a process and send a mail if the process doesnot come up within 2 minutes

Hi Friends,
I have a problem here and i need someone to solve this.

Let us consider there are two processes(abc & def).There is a script which kills these two processes(i.e killtheprocess abc). Here abc is the argument .
There is a automated system which detects which process is killed and it starts the process up within two minutes.This is the summary.

Now what i want is:-
The program should contain these features:_
1. It will take the PID of the two process.
2. kill the process with the help of the script(killtheproces. The
script should contain the two process names(i.e abc & def) .
3. After the process is killed, it should be able to detect if the two particular process has come up within two minutes by the help of the automated sytem
4. If the process comes up then it will send a mail to a group of people that everything is fine .
5. if the process doesnot come up then it should send a mail to a group of people that it needs to be manually started.
6. For confirmation that the process has indeed gone down and come up the two PIDs should be different.

It is urgent . Please help me out. If soemone needs some more clarification then please reply.

Thanks
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-11-2008, 12:39 PM
agn agn is offline
Member
User
 
Join Date: Feb 2008
My distro: OpenBSD/FreeBSD/Debian/Fedora/RHEL
Posts: 69
Rep Power: 1
agn is on a distinguished road
Default

Code:
#get process names
proc1=$(ps hc -o cmd -p $1)
proc2=$(ps hc -o cmd -p $2)

#kill 'em
kill $1 $2

#sleep for 2 mins
sleep 120

#check if they're running
( pgrep $proc1 && pgrep $proc2 ) > /dev/null

$? &&  mail -s "All OK" $users || mail -s "Needs manual restart" $users
Something like the above should work.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
process need more memory brijesh Linux software 3 12-13-2007 05:38 PM
httpd process vimalgoel Getting started tutorials 1 10-08-2007 12:40 AM
Interacting with a Linux Process through Scripts manikandakumar Shell scripting 1 08-17-2007 06:49 PM
how to enumerate currently running process hiimsa Coding in General 2 11-11-2006 03:02 PM
Linux krefilld process and what is it doing on my system? sweta Linux software 1 08-31-2006 01:16 AM


All times are GMT +5.5. The time now is 05:49 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36