Cron and open WRT on a GL-AR150 router

Hi,

I just received my GL-AR150 and I’m trying to switch off the wifi at certain times of the day (and if possible certain days of the week).

I already asked my question by email before buying it, and I got the answer that it was not possible with the standard GLiNET firmware but I could be done under open wrt, using “Cron”.

I opened the default web interface and saw an tab with “Cron” and some empty space where I could enter some text.

 

My first question is : is the AR150 using open wrt by default or should I install it myself (and how) ?

My second question is : how can I use the cron tab to set the wifi off at certain times ? (I saw somewhere on the internet that it was possible by adding command lines to certain files on the router… but I cannot figure out how)

 

Thank you very much, and all the best for this new year !

You already opened the web UI then that means it is OpenWRT already. You are using LUCI.

Here is a link for cron jobs in Openwrt: Cron and crontab [Old OpenWrt Wiki]

You will find how to config it to run command in some time of a day. It is quite strange syntax but it is not difficult.

The command to turn wifi on and off is

wifi on

wifi down

 

Hi thanks for your reply.

I’ve checked your links. On the first one for example, it is mentioned a “crontab file”. Where should I find this file ?

My interface is quite simple, I just have an empty text area :

Crontab

Is it the space where I am supposed to copy all the commands such as “wifi on” ?

Thanks for your help :slight_smile:

I think you have to write as to crond format.

For example from the docs

# Reboot at 4:30am every day
# Note: To avoid infinite reboot loop, wait 70 seconds
# and touch a file in /etc so clock will be set
# properly to 4:31 on reboot before cron starts.
30 4 * * * sleep 70 && touch /etc/banner && reboot

The crontab file can be found here: /etc/crontab

edit it with vi or nano (opkg update; opkg install nano) and adhere to the crond format explained here: https://wiki.openwrt.org/doc/howto/cron

So to disable your wifi at say 11pm every day and enable it again at 6am every day, you would insert this into crontab:

# Disable wifi at 11pm and enable at 6am every day
0 23 * * * uci set wireless.@wifi-device[0].disabled=1; uci commit wireless; wifi
0 6 * * * uci set wireless.@wifi-device[0].disabled=0; uci commit wireless; wifi

 

then save (Ctrl+x followed by ‘y’ in nano // esc followed by :wq and enter in vi) and reboot the device. Done!

thanks to you both, I pasted the command lines in the con “area” (cf. print screen above). I will check the next hour if it did work :slight_smile:

 

Out of curiosity, how do you access to the devices files /etc/crontab ? I just have access to the webpage unter 192.168.8.1…

When you talk about “vi” or “nano”, are these are the graphical interfaces (the print screen I made above ?)

And last question, is if possible to set a time at 23pm and 30min ? Or is it just “plain” hours ?

 

Thanks again for your help ! :slight_smile:

You access the crontab file via ssh using a console / terminal.

vi and nano or simply editor applications with which you can edit files in a terminal environment. Sort of like MS word, but solely with rudimentary functionality and just the resemblance of a minimal graphical interface.

I’m guessing you could just paste the lines I’ve posted on the webinterface; it’s just that I don’t really know it since I haven’t used it thus far.

Yea, you can set any time and date you want. Instead of “0 23 * * *” you would insert “30 23 * * *” for 11.30pm as the first number are minutes, the second number hours, the third number the day and so on.

I find the free tool WinSCP invaluable for editing Linux files from Windows. Just like editing in Notepad.
vi is for masochists.

Set it up like this
File protocol: SCP
Hostname: 192.168.x.1 (use your gateway or router GUI IPaddress) port: 22
username: (same as Luci/GUI) password: (same as Luci/GUI)

Use drop-down box next to the “SAVE” button and save the ID/password if you always have exclusive access to your Windows machine. I normally save the profile with the same name as the IP address. For example for the router gateway I have in one family household which is 192.168.7.1 for the gateway address, I save the profile names as 192.168.7.1 SCP, and that’s just to set it apart from something that could be running on the router that used another protocol like FTP, etc.