Jeremiah Bess wrote:
> I have a few process checking scripts like that running at work. I can
> try to find them on Monday if you like. But basically, you use "ps |
> grep apache" to find the process. If it returns blank, it restarts
> apache. it's a pretty simple script if you've written shell scripts
> before. I just did a Google search, and found a few you can adapt:
> 
> From
> http://cazatech.wordpress.com/2007/07/07/shell-script-restart-process-if-not-found-running/
> #!/bin/bash
> # check daemon
> ps -ef | grep -v grep | grep daemon
> # if not found - equals to 1, start it
> if [ $? -eq 1 ]
> then
> /sbin/init.d/daemon start
> else
> echo "eq 0 - daemon found - do nothing"
> fi
> 
> From http://www.linux.com/forums/topic/2458
> #!/bin/sh
> CMDNAME='apache2'
> RESTARTCMD='sudo /etc/init.d/apache2 restart'
> SLEEPTIME=5
> while test 1
> do
> OUTPUT=`ps ax | grep $CMDNAME | grep -v grep`
> if ! echo $OUTPUT | grep $CMDNAME 1>/dev/null ; then
> echo Restarting service...
> $RESTARTCMD
> fi
> sleep $SLEEPTIME
> done
> 
> Let us know what your final product is, and how it works out for you.

I'll probably work on something similar to that.  It seems crontab is
the only real solution to the problem, so oh well.

-- 
Registered Linux Addict #431495
http://profile.xfire.com/mrstalinman | John 3:16!
http://www.fsdev.net/ | http://lordsauron.wordpress.com/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to