Keeping a daemon running?

Bruce Marshall bmarsh at bmarsh.com
Tue Jan 12 13:04:29 PST 2010


On Tuesday 12 January 2010, Michael Hipp wrote:
> I have servers with a couple of daemons that regularly seem to silently die
> off. It would be great to have some tool that would detect this fault
>  condition and dutifully restart them. I know such things exist, was
>  wondering if anyone here could recommend something that does this?

Here's one way:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


KEEP THOSE DAEMONS RUNNING

Here is a script that will keep daemons running
if the decide to die for some unforseen reason.

This tip generously supported by: ken at theglobeandmail.com

-------------------- cut here -----------------



#!/bin/csh
#
# NAME
#   keepitup.csh - Keep demons up and running
#
# SYNOPSIS
#   keepitup.csh
#
# DESCRIPTION
#   If any of the following processes are down, then start them up
#   again.   This script can be run every few minutes from a crontab.
#
# AUTHOR
#   Ken Stevens <kstevens at globeandmail.ca>

foreach daemon ( \
        /opt/GIS/apps/EventDispatcher/scripts/EventDispatcher.pl \
        /opt/GIS/apps/CatchFTP/scripts/ProcessFTP.pl \
        /opt/GIS/apps/NewsHound/scripts/NewsHound.pl \
        )

        ps -e | fgrep `echo $daemon:t | cut -c1-8` > /dev/null

        if ( $status > 0 ) then
                echo Restarting $daemon
                date
                $daemon &
        endif

end



More information about the Linux-users mailing list