This question already has an answer here:
I'm building a wireless photoframe. The one thing I haven't been able to figure out is how to get my wifi connection back up using a recommended method.
Right now I edited /etc/network/interfaces so wlan0 is started at boot:
auto wlan0 iface wlan0 inet dhcp wireless-essid ourssid
This method works fine for booting. But I found that if I do not check the connection for a long time (could be a week) it might be down. So I should reconnect.
What I do now to verify the connection is working is downloading a file from the server that can't be cached (http://server.ext/ping.php?randomize=123456) If I fail to retrieve the file I assume that the connection is no longer working and I run a shell script like
#!/bin/bash ifconfig wlan0 up iwconfig wlan0 essid "ourssid" dhclient wlan0
And the connection comes back. But I can't find anything if this is in any way a good method.
Can this be improved upon, or is this already right?