#!/bin/sh

while true
do

ps auxw | grep httpd | grep -v grep > /dev/null

if [ $? != 0 ]
then
  echo "HTTP server crashed, restarting server"
  service httpd restart
fi

r=` wget -q --timeout=10 -t2 http://localhost/`

if [ $? -ne 0 ]
  then
    echo "HTTP server stuck, restarting"
    service httpd restart
  else
    echo "OK"
fi

echo "Waiting 60 seconds"
sleep 60

done

