I lost some money a few days ago because Apache crashed on my VPS that is running the Fake Mail Generator. I’m too cheap to pay for web monitoring, so I had no idea it happened until I noticed my earnings were down.
So I had a few options:
I went with option #4, and this is what I came up with:
#!/bin/sh string=`ps ax | grep -v grep | grep httpd` if [ -z "$string" ] then /usr/local/apache2/bin/apachectl start fi
I saved that to a file called keepApacheRunning and made it writable using chmod +x keepApacheRunning.
Basically this little script will see if httpd is in the process list, and if it isn’t, it will start Apache. Pretty straight forward.
To make it run, I added this entry to crontab:
* * * * * /www/keepApacheRunning
This will run it every minute. So my max downtime is about a minute. I can live with that.