Skip to content

Instantly share code, notes, and snippets.

@guruevi
Created September 22, 2016 17:27
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 guruevi/4b3ca1492d416a22fddace0c59ff2793 to your computer and use it in GitHub Desktop.
Save guruevi/4b3ca1492d416a22fddace0c59ff2793 to your computer and use it in GitHub Desktop.
Reboot if network connection is down
#!/bin/sh
#put in /etc/cron.daily
ping -c4 8.8.8.8 > /dev/null
if [ $? != 0 ]
then
sudo /sbin/shutdown -r now
fi
#!/bin/sh
#put in /etc/cron.hourly
ping -c4 8.8.8.8 > /dev/null
if [ $? != 0 ]
then
echo "No network connection, restarting wlan0"
/sbin/ifdown 'wlan0'
sleep 5
/sbin/ifup --force 'wlan0'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment