Skip to content

Instantly share code, notes, and snippets.

@leonmak
Created August 17, 2017 19:35
Show Gist options
  • Save leonmak/f8092205cda78ded201615be6c5d40d6 to your computer and use it in GitHub Desktop.
Save leonmak/f8092205cda78ded201615be6c5d40d6 to your computer and use it in GitHub Desktop.
Raspberry Pi cron wifi restart
#!/bin/bash
# The IP for the server you wish to ping (8.8.8.8 is a public Google DNS server)
SERVER=8.8.8.8
# Only send two pings, sending output to /dev/null
ping -c2 ${SERVER} > /dev/null
# If the return code from ping ($?) is not 0 (meaning there was an error)
if [ $? != 0 ]
then
# Restart the wireless interface
ifdown --force wlan0
ifup wlan0
fi
# add the line below to /etc/crontab to check every 5 min
# */5 * * * * root /usr/local/bin/wifi_rebooter.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment