Last active
August 8, 2016 10:15
-
-
Save izmailoff/302fe6aecc54d79cb49c to your computer and use it in GitHub Desktop.
Check webpage/API continuously for availability
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 | |
# Keep calling some API every second and check that it's working (status 200). | |
# If any other HTTP status is received print an error. | |
# | |
# Useful for observing server downtime and such. | |
while true | |
do | |
status="$(curl -sL -w '%{http_code}' https://api.com/something -o /dev/null)" | |
if [ "200" != "$status" ] | |
then echo "FAILED with "$status | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment