Skip to content

Instantly share code, notes, and snippets.

@jef-n
Created December 12, 2012 18:23
Show Gist options
  • Save jef-n/4270244 to your computer and use it in GitHub Desktop.
Save jef-n/4270244 to your computer and use it in GitHub Desktop.
ping apache
#!/bin/bash
if [ -f /var/run/apache2.pid ]; then
if kill -0 $(</var/run/apache2.pid); then
if ! wget -q --timeout=10 --tries=1 -O /dev/null http://localhost; then
echo "apache running, but not responding"
ps auxwf
date
tail -20 /var/log/apache2/*.log
/etc/init.d/apache2 restart
sleep 20
if ! wget -q --timeout=10 --tries=1 -O /dev/null http://localhost; then
echo "apache restarted, but still not responding"
else
echo "apache back up and responding"
fi
fi
else
echo "stale apache pid file found"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment