Last active
May 17, 2017 09:50
-
-
Save erickvasilev/34c35f07e7b238a356047cb30ba9c762 to your computer and use it in GitHub Desktop.
Bash Script - Check If Server is Down/Up
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
#!/bin/bash | |
# scanning website and save to status.txt | |
wget -q -O /var/www/test/status.txt bahrulilmi.com --timeout 10 -t 1 | |
cd /var/www/test/ | |
File=status.txt | |
# check if there is <title> metadata , if site is not accessible / timeout, file will be empty | |
if grep -q title "$File"; | |
then | |
echo "server is up" | |
else | |
echo "Oops!! server is down" | |
# restart the server (VULTR API), change with your own | |
curl -H 'API-Key: xxxxxxxxxxxxx' https://api.vultr.com/v1/server/reboot --data 'SUBID=xxxxxxx' | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment