Created
May 26, 2015 16:44
-
-
Save mindware/781090e2f1d19356bec1 to your computer and use it in GitHub Desktop.
Cronjob to check if we're online
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/zsh | |
# Saved in ~/online-check.sh and in a cron job as: | |
# * * * * * ~/online-check.sh | |
local offline=`dig 8.8.8.8 +time=1 +short google.com A | grep -c "no servers could be reached"` | |
if [[ "$offline" == "0" ]]; then | |
rm ~/.offline | |
else | |
touch ~/.offline | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment