Created
June 10, 2016 22:20
-
-
Save aklinkert/e104cdadefae456c98de47a8ca10232f to your computer and use it in GitHub Desktop.
Bash ping loop
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
#!/usr/bin/env bash | |
while true; do | |
result="$(curl -v "$1" 2>&1)" | |
code="$(echo "${result}" | tail -n1)" | |
if [ "${code}" != "ok" ]; then | |
echo "Failure at $(date)" | |
echo "code: ${code}" | |
echo "result: ${result}" | |
printf "\n\n-----------------------------------------------------------------------------------\n\n" | |
else | |
echo "$(date) Ping ok." | |
fi | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment