Created
April 29, 2017 11:54
-
-
Save homam/94bc7f868f35f0f144cd7598ed729d9e to your computer and use it in GitHub Desktop.
Check if internet connection is alive every second
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
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