Server Administration: automatically restarting services
Dennis Ruzeski
dennisr at corp.kanoodle.com
Thu Apr 8 08:25:44 EDT 2004
This is a pretty simple shell script from UGU.com. The basic idea is
that it greps for the process. If it doesn't see it, it restarts it..
This one is ok, I've got a ksh version that's a little neater and a
friend of mine wrote a perl script that's great, but I can't get a hold
of him to get a copy.
>From UGU.com
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
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
-----Original Message-----
From: Matt Cristantello [mailto:matt at crazy42.org]
Sent: Thursday, April 08, 2004 12:39 AM
To: nflug at nflug.org
Subject: Server Administration: automatically restarting services
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hey,
I was just wondering if any of you have come across any projects to
automatically restart crashed or broken services (such as sshd, apache,
etc.) in linux. I have rcN.d and init.d scripts set up, but I'd like
something to check, say every five minutes, and see if a process is
still running/is in a good state, then restart it if it's not. I can do
something similar using ps -A, grep, and then running the init.d script
if necessary, but I'd like somethign a little more automatic. If nothing
like this has been done, I'll look into writing something and releasing
it under the GPL or something like that.
Thanks,
~Matt
- --
************************************************************************
****
"When trouble arises and things look bad, there is always one
individual who perceives a solution and is willing to take command.
Very often, that individual is crazy."
- -Dave Barry
************************************************************************
****
~ Matthew D. Cristantello
~ matt at crazy42.org
~ 716-472-3833 (cell)
~ AIM: Matt977
************************************************************************
****
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAdNdWi3I4xV1yeBQRAgdxAJ4iJzw5aV/nEwg5iFkpyFjuSMyj/ACgkyH5
mfvzrlkH8IJdTAf/MsDREhY=
=TS4d
-----END PGP SIGNATURE-----
More information about the nflug
mailing list