Last active
October 18, 2017 10:38
-
-
Save czyang/664c996b94c8ece3c314279bf6a36566 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| # This script monitoring a web page, if get any error the error infomation will output to the log file. | |
| # Usage: nohup ./monitoring_web_page.sh http://127.0.0.1 2>&1 >/tmp/monitoring_web_page.log & | |
| SERVER=$1 | |
| PAUSE=10 | |
| while true | |
| do | |
| if curl -s --head $SERVER | grep "200 OK" > /dev/null | |
| then | |
| echo "The HTTP server on $SERVER is up! $(date)" > /dev/null | |
| else | |
| echo "The HTTP server on $SERVER is down! $(date)" | |
| fi | |
| sleep $PAUSE | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment