Skip to content

Instantly share code, notes, and snippets.

@nczz
Created September 1, 2017 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nczz/baab022724a04d9770c6c7d2f23e1b18 to your computer and use it in GitHub Desktop.
Save nczz/baab022724a04d9770c6c7d2f23e1b18 to your computer and use it in GitHub Desktop.
伺服器自我檢查網站健康度
#!/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