Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
crontab -e
*/5 * * * * /usr/bin/sudo -H /home/pi/my-scripts/checkwifi.sh >> /dev/null 2>&1
# http://weworkweplay.com/play/rebooting-the-raspberry-pi-when-it-loses-wireless-connection-wifi/
# Check wifi connection...
ping -c4 192.168.179.3 > /dev/null
# '$?' is the exit code of previous ping command.
# If exit code != 0 (failure)...
if [ $? != 0 ]
then
echo "$(date): No network connection, restarting wlan0" >> /var/log/checkwifi.log
# deactivate wifi...
/sbin/ifdown 'wlan0'
sleep 5
# Restart wifi...
/sbin/ifup --force 'wlan0'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment