Created
April 27, 2014 10:59
-
-
Save oazabir/11342910 to your computer and use it in GitHub Desktop.
Check if site responds, if not restart apache and mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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