Cover V10, I02
Article
Listing 1

feb2001.tar


Listing 1 Complete script with comments

#!/bin/csh

#
# Viagra for BSD
#
# A simple little csh script for keeping services up and
# at the ready on a BSD system. Taken from Unix Guru
# Universe (http://www.ugu.com), then hacked together
# to run on BSD and given a little bit more versatility by
# James O'Gorman (jameso@elwood.net).
#

# Define the process to look for

foreach DAEMON ( inetd apache )

# Look for the process and send any output to /dev/null

    ps -cax | fgrep "$DAEMON:t" | cut -c27-80 > /dev/null

# If the process is not running, start it and give me
# the date and time that it happened

    if ( $status > 0) then
        echo "Restarting $DAEMON"
        date

# Have a dir with scripts named the process name that
# you are watching for, the scripts in there will
# restart the process. It is up to you to write the
# scripts and make them start the app correctly. But,
# that is not so hard now is it? We do this so that
# we have a bit more control over how the process starts.

        /root/scripts/start/$DAEMON &

# And end the script

    endif
end