Skip to content

Instantly share code, notes, and snippets.

@Amitesh
Created August 18, 2012 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amitesh/3385033 to your computer and use it in GitHub Desktop.
Save Amitesh/3385033 to your computer and use it in GitHub Desktop.
Apache cron watch
#apache-cron-watcher.sh
#!/bin/sh
run=`ps ax | grep /usr/sbin/apache2 | grep -v grep | cut -c1-5 | paste -s -`
if [ "$run" ];
then
echo “Apache is running”
else
echo "Apache not running"
/etc/init.d/apache2 restart
fi
# Crontab settings
# m h dom mon dow command
# check on each 5 minutes
*/5 * * * * /home/user/apache-cron-watcher.sh > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment