Skip to content

Instantly share code, notes, and snippets.

@aklinkert
Created June 10, 2016 22:20
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 aklinkert/e104cdadefae456c98de47a8ca10232f to your computer and use it in GitHub Desktop.
Save aklinkert/e104cdadefae456c98de47a8ca10232f to your computer and use it in GitHub Desktop.
Bash ping loop
#!/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