Wireless schedule via crontab?

General discussion about Gargoyle, OpenWrt or anything else even remotely related to the project

Moderator: Moderators

ddsforlife
Posts: 13
Joined: Sun Dec 04, 2011 5:46 pm
Location: NC

Wireless schedule via crontab?

Post by ddsforlife »

RouterStation Pro
Gargoyle 1.5.1

Everything works smoothly (finally!)...I'm wanting to disable the wireless users I have at a specific time during the day...say 10:45am-1:00pm

What is the best method to do this?

I searched the forum and someone mentioned setting up a cron job. Is this reliable? ...and if so, does it mess anything else up? Also, if it's recommended, how exactly do I go about doing it?

ispyisail
Moderator
Posts: 5185
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: Wireless schedule via crontab?

Post by ispyisail »

http://wiki.openwrt.org/doc/uci/wireles ... p.wireless

Start/Stop Wireless

Wireless interfaces are brought up and down with the wifi command. To (re)start the wireless after a configuration change, use wifi, to disable the wireless, run wifi down. In case your platform carries multiple wireless devices it is possible to start or run down each of them individually by making the wifi command be followed by the device name as a second parameter. Note: The wifi command has an optional first parameter that defaults to 'up' , i.e. start the device. To make the second parameter indeed a second parameter it is mandatory to give a first parameter which can be anything except down. E.g. to start the interface wlan2 issue: wifi up wlan2; to stop that interface: wifi down wlan2. If the platform has also e.g. wlan0 and wlan1 these will not be touched by stopping or starting wlan2 selectively.

ispyisail
Moderator
Posts: 5185
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: Wireless schedule via crontab?

Post by ispyisail »

Done some tests but not full tests

SSH into your router with putty or winSCP

edit /etc/crontabs/root

Add the lines

Code: Select all

30 22 * * * wifi down
30 6 * * * wifi up

minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday), command

30 22 * * * wifi down
Turn wifi off at 10:30pm

30 6 * * * wifi up
Turn wifi on at 6:30pm

Tell us your results then I will add it to the wiki

ddsforlife
Posts: 13
Joined: Sun Dec 04, 2011 5:46 pm
Location: NC

Re: Wireless schedule via crontab?

Post by ddsforlife »

Thanks! I will try that...

By the way...how do I edit that? I read and see all these things about "editing" this or that and I have no idea the exact way of doing it...I'm a very fast learner if I know where to get the information.

I can putty into the router fine and I can run "crontab -l" to see what's in the cron file and stuff like that. Just wondering how to edit the crontabs root thing? :)

ispyisail
Moderator
Posts: 5185
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: Wireless schedule via crontab?

Post by ispyisail »

winSCP is the easiest
http://winscp.net/eng/index.php

With putty you can use "vi" but tricky to use
http://www.yolinux.com/TUTORIALS/LinuxT ... ed_vi.html

Code: Select all

vi /etc/crontabs/root
 
or I like "nano"

Code: Select all

opkg update
opkg install nano
nano /etc/crontabs/root
you don't need a manual for nano

ddsforlife
Posts: 13
Joined: Sun Dec 04, 2011 5:46 pm
Location: NC

Re: Wireless schedule via crontab?

Post by ddsforlife »

I tried putty and used vi and added:

Code: Select all

30 14 * * * wifi down
45 14 * * * wifi up
Unfortunately that did nothing.

So I've searched the forum and found this code:

Code: Select all

50 14 * * * /sbin/ifconfig wlan0 up 
00 15 * * * /sbin/ifconfig wlan0 down
That code turned the wifi off and then turned it back on at the appropriate time. Sadly, after that...the wifi just got buggy and kept going off and on and off and on and off and on and was useless. I tried to connect my mac and it wouldn't even connect. The pc notebook I use would connect but it just would barely get to google.com and then the connection would drop to zero. In the taskbar at the bottom, the wireless would say that it was on, but the connection would go from 54mbps to 0mbps and then back to 54mbps and 0 mbps and 54mbps indefinitely.

I was able to restart the router and then it stayed on 54mbps fine. I'm not sure the bug here? If it goes off and comes back on...I shouldn't have to "reboot" the router.

ispyisail
Moderator
Posts: 5185
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: Wireless schedule via crontab?

Post by ispyisail »

Code: Select all

30 14 * * * wifi down
45 14 * * * wifi up
I did some tests and it did work

I made a 5 minute timer

Code: Select all

0,10,20,30.40, 50 * * * * wifi down
5, 15. 25, 35, 45, 55 * * * * wifi up
see

https://help.ubuntu.com/community/CronHowto

and

http://martybugs.net/wireless/openwrt/cron.cgi

I did not try 10:30pm off and 6:30an on

ispyisail
Moderator
Posts: 5185
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: Wireless schedule via crontab?

Post by ispyisail »

I tried putty and used vi and added:

Code: Select all
30 14 * * * wifi down
45 14 * * * wifi up



Unfortunately that did nothing.
did you reboot the router?

ddsforlife
Posts: 13
Joined: Sun Dec 04, 2011 5:46 pm
Location: NC

Re: Wireless schedule via crontab?

Post by ddsforlife »

ispyisail wrote:
I tried putty and used vi and added:

Code: Select all
30 14 * * * wifi down
45 14 * * * wifi up



Unfortunately that did nothing.
did you reboot the router?
No... so you're recommending me use the above code and reboot and see if it works?

ispyisail
Moderator
Posts: 5185
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: Wireless schedule via crontab?

Post by ispyisail »

No... so you're recommending me use the above code and reboot and see if it works?
Yes

Do the 5 min on off test above just to test

Post Reply