Being fairly new to linux and the cmd line, i was wondering how do I go about making this small router turn on/off wifi on a weekly schedule.
Monday: 1830/0630
Tuesday: 1830/0630
…
Would you want to restart it weekly? It seems there has a solution on another post. [GL-MT300N-V2] turning wi-fi on-off automatically - #7 by psigli
I think i have it worked out but it doesn’t want to co-operate with Cron Settings.
I have a question about the cron job.
- Im wondering if this is just a toggle switch of a command where it will place it in the opposite state?
wifionoff
Just as a test I would have this in Scheduled Tasks.
00 07 * * Mon,Tue,Wed,Thu,Fri /usr/bin/wifionoff
10 07 * * Mon,Tue,Wed,Thu,Fri /usr/bin/wifionoff
This turned off the Wifi to the Client side only.
Now when I logged through SSH and made my way to /usr/bin and used the command wifionoff
, it turned the whole wireless off and turned off my internet connection. This is the state I want.
I’m wondering what am I doing wrong or is this something else.
Yes, it just calls a shell script.
What’s it? Do you want to disable the wan connection?
Yes,
I want to disable the WAN side on a schedule
In this case, you should modify /usr/bin/wifioff file.
#!/bin/sh
device=$(uci -q get wireless.@wifi-device[0].disabled)
ap=$(uci -q get wireless.@wifi-iface[0].disabled)
if [ "$device" = "1" -o "$ap" = "1" ]; then
uci set wireless.@wifi-device[0].disabled=0
uci set wireless.@wifi-iface[0].disabled=0
uci set network.wan.disabled=0
else
uci set wireless.@wifi-device[0].disabled=1
uci set wireless.@wifi-iface[0].disabled=1
uci set network.wan.disabled=1
fi
uci commit wireless
uci commit network
wifi
/etc/init.d/network reload
Tested it and
It only disconnected the client side Wifi only.
Turns out the the solution was a lot simpler that I thought
I used the following example (seen this over at Openwrt forums)
00 07 * * Mon,Tue,Wed,Thu,Fri wifi down
10 07 * * Mon,Tue,Wed,Thu,Fri wifi up
seems to work exactly the way I want.