Restart Wifi from Script

I have an issue with some wifi clients dropping off the network for some reason, more of a problem being that they are part of my home automation, it gets cold when the heating won’t come on because it is unreachable over wifi! :slight_smile:

If I restart the wifi, the devices come back to life…

This isn’t a fix but a work around till I can figure out why…

So I would like to put in a little cron job to restart the wireless network… basically replicating clicking this button:

Pointers to how I could do this would be appreciated please?

The command you after searching for is “wifi”.

1 Like

You can use it in cron as for example
*/5 * * * * wifi reload
or
*/5 * * * * wifi down && wifi
where you can change */5 which means command will be executed each 60/5 minutes (please see man pages for crown) to any preferred value… Please note that WiFi will be interrupted even if working due to wifi reload or wifi down/up crown command :wink:

1 Like

Thanks guys - useful info will test and see how it goes.

Maybe it is also useful to check if the adapters in question are still connected to the respective AP before a “blind” wifi restart every n minutes/hours, e.g.:

root@blackhole2:~# iwinfo wlan0 assoclist
D2:xx:xx:2x:xE:xx  -47 dBm / -86 dBm (SNR 39)  0 ms ago
	RX: 144.4 MBit/s, MCS 15, 20MHz                 1037 Pkts.
	TX: 144.4 MBit/s, MCS 15, 20MHz                  593 Pkts.
	expected throughput: unknown

needs just a little bit of scripting … :wink: