[CentOS] centos command to monitor a process for exit

Thu Jan 10 15:30:29 UTC 2008
Ray Van Dolson <rayvd at bludgeon.org>

On Thu, Jan 10, 2008 at 10:22:56AM -0500, Jerry Geis wrote:
> Is there a command that will monitor a process for exiting (crash or
> normal exit) and then execute another command based on the said
> process no longer being active?

You can use SNMP to do this.  It will set a flag in a certain OID which
you then need to monitor.  I _believe_ you may even be able to tell
snmpd itself to call a process, but I don't recall on that.

Check the man pages.

>
> Or is there a "wrapper" command that runs a process and when that
> process exists due to crashing or just exiting normally) that another
> process can be run.

You might look into something like daemontools[1].  It might be a
little overly complex.  You could certainly script something yourself.
However, daemontools are quite reliable.

Ray

[1]: http://cr.yp.to/daemontools.html