Automatically Reconnecting WiFi on Openwrt

Hello ,
I want to add the following script ( ) in /usr/local/bin ,
and make it executable by running!

chmod +x /usr/local/bin/

schedule in /crontab

*/5 * * * * root /usr/local/bin/

& I do not know how there is a solution to that ?!

Wifi_rebooster script


# The IP for the server you wish to ping ( is a public Google DNS server)

# Only send two pings, sending output to /dev/null
ping -c2 ${SERVER} > /dev/null

# If the return code from ping ($?) is not 0 (meaning there was an error)
if [ $? != 0 ]
    # Restart the wireless interface
    ifdown --force wlan0
    ifup wlan0

Thanks ..

The preformat button </> should be helpful to you

Managing the wireless interfaces, assuming you really want to "bounce" them every 5 minutes, is perhaps better done with wifi down and wifi up.

jeff@office:~$ wifi --help
Usage: /sbin/wifi [config|up|down|reload|status]
enables (default), disables or configures devices not yet configured.

Checking for wireless connectivity is perhaps better done with iw dev <name of wlan device> station dump or, even better, a ubus call to get associated stations.

cron works pretty much like any other `nix system.

1 Like