Created
April 26, 2020 16:34
-
-
Save jhalitschke/8bd05e095e35d05f67bfa2e86e256e4a to your computer and use it in GitHub Desktop.
check internet connectivity
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
#!/bin/bash | |
# check internet connectivity | |
# i use it to check and log every the connection | |
# just add a cron job with crontab -e | |
# * * * * * ~/check_connectivity.sh >> ~/check_connectivity.log | |
DATE=`date '+%Y-%m-%d %H:%M:%S'` | |
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then | |
echo "$DATE - IPv4 is up" | |
else | |
echo "$DATE - IPv4 is down" | |
fi | |
if nc -zw1 google.com 443; then | |
echo "$DATE - We have connectivity to google.com." | |
else | |
echo "$DATE - No connection to google.com possible." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment