Tuesday, June 30, 2015

Raspberry Pi Auto reconnect Wi-fi

# create script
sudo vi /opt/wifiReconnect.sh

#!/bin/bash

   if /sbin/ifconfig wlan0 | grep -q "inet addr:" ; then
    exit 0
   else
      logger -t $0 "Wifi connection down! Attempting reconnection.."
      /sbin/ifdown --force wlan0
      /sbin/ifup wlan0
   fi






# Make script executable
sudo chmod +x /opt/wifiReconnect.sh

# Add as cron and monitor every 5 mins
*/5 * * * * /opt/wifiReconnect.sh >> /var/log/syslog 2>&1

No comments: