Hi Friends,
I am new to this forum as well as new to shell scripting.
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(killtheprocess). 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

sounds like home work, please try to attempt to write the script then we can help you out

well the ps command returns the running time. so something like ps -ax|grep 2:00 will give you the process that has been running for 2 minutes, as well as the PID and the filename
after that take the first 4 simbols from the ps output (the PID) and kill that process

Agreed,

If you have something, post it and we can help you make it work better.

For a general "is it up at all", just us ps and grep, much like above:

$isitup=`ps -ef|grep "[a]bc"`

and test that string to determine if your process is running at all.

Best wishes,

, Mike

I feel thsi way it can be done,
ps -C <process_name>
redirect this output to any file
then use while loop use head and tail command so that process can be killed one by one.
Then give sleep 120 seconds
then use the same process but use if loop to send the message
try write the code so that we can correct you

This article has been dead for over six months. Start a new discussion instead.