Skip to content

Instantly share code, notes, and snippets.

@czyang
Last active October 18, 2017 10:38
Show Gist options
  • Select an option

  • Save czyang/664c996b94c8ece3c314279bf6a36566 to your computer and use it in GitHub Desktop.

Select an option

Save czyang/664c996b94c8ece3c314279bf6a36566 to your computer and use it in GitHub Desktop.
#!/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