auto restarting a daemon process with RHEL's init system

Michael Torrie torriem at
Tue Jun 30 14:00:50 MDT 2009

Is there any utility program that can wrap a daemon running in an init
script on RHEL 5 that can auto-restart the actual daemon process when it
crashes?  Obviously a crashing daemon isn't desirable, but sometimes it
happens and in this case a restart is sufficient and desired.  I'd like
to still work with a script from /etc/init.d, though, so the standard
runtime logic can apply to it.  Does anyone have a good solution?  I
thought about writing a little python program to fork the daemon child
(gotta love it!) and monitor it for SIGTERM or SIGKILL and restart it.
The init.d script could treat the python program as the daemon itself.
If the python script got a kill signal it would pass it on to the child
and then exit.  The changes of the python program dying are much smaller
than the daemon I'm trying to respawn.

Are there any existing solutions?  A cron watchdog seems a little crude
to me (and has no knowledge of runlevels)  I also know how to use
/etc/inittab, but that seems a little crude (and harder to maintain).

I used to think Apple's launchd was a convoluted non-necessity compared
to the familiar system V init system.  But now I find myself in a
position where it would be just what I need.

More information about the PLUG mailing list