Categories
BSD/Linux DrupalRecover Tech

RaspberryPi wifi restart

(2016 update) I actually wondered where this one went!

I’ve got a Raspberry Pi that keeps losing its wifi connection whenever the microwave runs too long. Here’s at least one way to get around this since the wifi doesn’t seem to rescan on its own.

Firstly – create a script that will check for an internet connection and restart the interface if the connection is down:

#!/bin/bash

TESTIP=google.com

ping -c4 ${TESTIP} > /dev/null

if [ $? != 0 ]

then

    logger -t $0 "WiFi seems down, restarting"

    echo "WiFi seems down, restarting"

    sudo /sbin/ifdown --force wlan0

    sudo /sbin/ifup wlan0

else

    logger -t $0 "WiFi seems up."

    echo "WiFi seems up."

fi

Then create a crontab entry that runs the script every 15 minutes (or whatever). Voila! This seems to work well so far.

Leave a Reply

Your email address will not be published. Required fields are marked *