Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for running process

Status
Not open for further replies.

logic4fun1

Programmer
Jun 29, 2006
6
US
I have a situation where i have to check for same process on two boxes

Goals :
1. Check on the other box and see if it is running or not.
2. if not running then start it on the local box. If running just Sleep .

I thought of using rsh/rcmd along with ps |elf but at a given time the process should be running only on one box. So i am worried if my ps fails and it starts off the application i would be in a problem.

Any logic how to implement this ??

thanks
 
On UNIX, a lot of the system process' will create a file with the process id, for instance named creates named.pid.

It uses signals to remove this file in the event of a abnormal termination.

On normal term, it simply removes the file.

rcmd is one way, another way more complicated would be using sockets.


 
I see a lot of potential for race conditions which result in the process being run on both machines at the same time.

Also, is network failure the same as program failure?

Opening a network connection to your live program, sending "are you alive?", and getting back "I am alive" in response seems OK to me.

What happens if you power on both machines at the same time? Is one of them configured as "master" to start your program automatically, and "reserve" is just sitting there waiting to take over if necessary?


--
 
I'd say the process needs to be started from a daemon sitting on a socket, on one machine only, acting as a queue manager.

It can start the process on the appropriate machine knowing that it hasn't already started on that or the other or that it has been notified in some way (probably death of child setting flag variable) that the process it last started has now finished.

It should use remote protocol to start the process even if the process will be on the same machine as the daemon to simplify things and the daemon could even be on a third machine.

==========================================
toff.jpg
Some cause happiness wherever they go; others whenever they go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top