Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check if site responds, if not restart apache and mysql
FILE=/home/siteup.log
SITE=http://quranerkotha.com
SIZE=`stat -c %s $FILE`
# Delete the file if it is over 1MB already
if [ $SIZE -ge 1000000 ]; then
rm FILE
fi
# IF the site doesn't response within 15 sec, time to kill apache and mysql
if wget --timeout=15 --read-timeout=15 -O /dev/null -q $SITE
then
echo "Site is up" >> $FILE
date >> $FILE
else
echo "Site is down" >> $FILE
date >> $FILE
/usr/bin/killall apache2 >> $FILE
/usr/sbin/service mysql restart >> $FILE
/usr/sbin/service apache2 restart >> $FILE
wget --timeout=30 --read-timeout=30 -O /dev/null -q $SITE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.