Automatically Reconnect WIFI (Debian, Ubuntu etc.)

The Problem

For several reason I do not have access to LAN and thus have to rely on WIFI for my mining rigs. It is fine for most of the time, but the shit hits the fan, when the connection drops for one reason or another.

The Solution

wlan=`/sbin/ifconfig wlan1 | grep inet\ addr | wc -l`
if [ $wlan -eq 0 ]; then
service network-manager restart
Note: It's either wlan0 or wlan1. Check with sudo ifconfig.

Save the script and make it executable.

sudo chmod +x

Now there are several ways of making sure that our script is being executed every x minutes. The easiest way of accomplishing that I think is by using the command watch.
sudo su
watch -n 600 sh

What it does is execute our script every 600 seconds.

Or you implement a so called cron job  

sudo crontab -e

Add the following

*/5 * * * * sh /home/username/

*/5 * * * * means that the task will run every 5 minutes.


Post a Comment

Popular posts from this blog

How to be anonymous on the internet (99-100%)

Deep Web Link List (.onion)

Automatically Check The Raspberry Pi's Temperature (+Prevent Overheating)