Okay now in your /root (or whever you want it) directory we're going to create a file:
Now mark it executable
Code:
chmod +x automagic.sh
Now open it up with vi or nano or mc or whatever text editor you use, and make it look like this:
Code:
#!/bin/bash
#automagic.sh - Automagically restart httpd if it dies!
netstat -l | grep http | wc -l | awk '{if ($1 == 0) system("service httpd restart") }'
Save it.
Now open up your crontab:
Go to the last line, and add this:
Code:
0-59/1 * * * * /root/automagic.sh
Now your system will check once per minute if httpd is actually working, and if not, restart the process for you!
Bookmarks