Here is a small script to restart The apache server.
Code:
#!/bin/bash
pgrep http > /dev/null
if [ $? -ne 0 ] ; then
/etc/init.d/httpd start
fi
Explanation the pgrep runs if the command is successful the return exit status of the command pgrep http will return 0
then with that condition met the command /etc/init.d/httpd start will be sent to start apache.
Very simple and can be tweaked to almost any type of daemon service. MySQL , Sendmail
If there is something wrong with this script let me know. I am still a newbie.
Thanks