Last active
May 27, 2016 03:53
-
-
Save dmelo/fb935be074100d0c48f9d847f2eaf631 to your computer and use it in GitHub Desktop.
watchdog script to reboot my old notebook every time it loses connection with the network router.
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 | |
function flog() { | |
DATE=$(date) | |
echo "$DATE - $1" | |
} | |
function freboot() { | |
echo "TIME TO REBOOT" | |
/usr/sbin/reboot | |
} | |
while [ 1 ] | |
do | |
COUNT=$(ping -c 1 192.168.0.1 > /dev/null && echo 0 || echo `expr $COUNT + 1`) | |
flog "$([ $COUNT -ge 5 ] && freboot || echo "COUNT=$COUNT")" | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment