Skip to content

Instantly share code, notes, and snippets.

@homam
Created April 29, 2017 11:54
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 homam/94bc7f868f35f0f144cd7598ed729d9e to your computer and use it in GitHub Desktop.
Save homam/94bc7f868f35f0f144cd7598ed729d9e to your computer and use it in GitHub Desktop.
Check if internet connection is alive every second
while true
do
echo -e "GET http://google.com HTTP/1.0\n\n" | nc -w2 google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo $(date +"%T") " Online"
else
echo $(date +"%T")" Offline"
say "offline"
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment