Here is a small script to restart The apache server.
pgrep http > /dev/null
if [ $? -ne 0 ] ; then
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.