Created
September 1, 2017 03:03
-
-
Save nczz/baab022724a04d9770c6c7d2f23e1b18 to your computer and use it in GitHub Desktop.
伺服器自我檢查網站健康度
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 | |
now="$(date +"%c")" | |
statuscode=`wget --spider -S "https://www.mxp.tw" 2>&1 | grep "HTTP/" | awk '{print $2}'` | |
if [ "$statuscode" != "200" ] | |
then | |
sudo /path/to/server restart | |
echo "restart in $now">>/home/username/crush_log.txt; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment