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. Jeremiah E. Bess Network Ninja, Penguin Geek, Father of four On Sat, Sep 6, 2008 at 1:34 AM, Chris Miller <[EMAIL PROTECTED]>wrote: > > I've got a weird little problem. > > I run my webserver - all aspects. I am root. I am powerful. I am > confused. > > But that's to be expected. > > So I've got this system set up and it works beautifully. Apache sends > requests to a Mongrel Rails thread so Ruby can run my site, and then > Apache will run Subversion on the site really fast. The only issue is > that once in a while I run out of memory (this being an inexpensive > VPS) and it scares one of my system's services, and it just gives up > the ghost and dies. Sometimes it's Apache. Other times it's Sendmail > (which is annoying, because if sendmail isn't alive it's not > immediately obvious, so it can take a week or two to realize "gee, > Redmine isn't sending me any email! I wonder why!"). Other times its > the Mongrel threads themselves. > > So I created cron scripts to restart Apache every day, and to verify > the status of the mongrel threads every hour. But fate being what it > is, they're down when I'm trying to use the site, and therefore I have > to log in and start them up. > > I was wondering if anyone knew of a tool that could provide a bit more > immediate results, constantly verifying that a process or daemon is > running, and to start it if it's not. I'd settle for something that > runs every minute (that isn't a cron job, since they leave me feeling > very icky, kind of like a lame hack. It works, but there should be a > better solution). > > I was thinking that there's bound to be a kind of "process nazi" tool > that'll keep things running smoothly, but I don't know of any. I'm > running Debian 5. > > Thanks in advance for any help/suggestions! > > Registered Linux Addict #431495 > http://profile.xfire.com/mrstalinman | John 3:16! > http://www.fsdev.net/ | http://lordsauron.wordpress.com/ > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Linux Users Group. To post a message, send email to [email protected] To unsubscribe, send email to [EMAIL PROTECTED] For more options, visit our group at http://groups.google.com/group/linuxusersgroup -~----------~----~----~----~------~----~------~--~---
