Cron to reset in case of power failure

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
Brian_E
DD-WRT Novice


Joined: 20 May 2012
Posts: 21

PostPosted: Sun Aug 05, 2012 13:20    Post subject: Cron to reset in case of power failure Reply with quote
I have set up a cron script to switch off the router wireless radio after 11.00pm and back on at 6.00am. I have also put in a startup script for the wireless radio to be down if the router if rebooted. However, could I add some more cron jobs to wake up the wireless signal after a short time in the event of a power failure (in case I am not at home and someone else wanted to use the wireless connection)? For instance, could I add a series of cron jobs to do this every hour, like this:-


0 09 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 10 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 11 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 12 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20

If the above would work, could I set it to do this every 30 minutes like this (which is what I would really like to do:-


0 09 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 09 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 10 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 10 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20

0 11 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 11 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 12 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 12 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
Sponsor
aceror
DD-WRT User


Joined: 27 Oct 2010
Posts: 88

PostPosted: Sun Aug 05, 2012 23:59    Post subject: Re: Cron to reset in case of power failure Reply with quote
Brian_E wrote:
I have set up a cron script to switch off the router wireless radio after 11.00pm and back on at 6.00am. I have also put in a startup script for the wireless radio to be down if the router if rebooted. However, could I add some more cron jobs to wake up the wireless signal after a short time in the event of a power failure (in case I am not at home and someone else wanted to use the wireless connection)? For instance, could I add a series of cron jobs to do this every hour, like this:-


0 09 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 10 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 11 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 12 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20

If the above would work, could I set it to do this every 30 minutes like this (which is what I would really like to do:-


0 09 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 09 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 10 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 10 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20

0 11 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 11 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 12 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 12 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20


I guess you want this

*/30 * * * * root /sbin/ifconfig ath0 up

The command about runs every 30 min.
Brian_E
DD-WRT Novice


Joined: 20 May 2012
Posts: 21

PostPosted: Mon Aug 06, 2012 10:24    Post subject: Reply with quote
Almost there I think, but I only want this command to run between the on time (6.00am) and off time (11.00pm). I tried something like this but it didn't work:-

0 6-22/1 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
30 6-22/1 * * * root /sbin/ifconfig ath0 up; /usr/sbin/iwconfig ath0 txpower 20
0 23 * * * root /sbin/ifconfig ath0 down; /usr/sbin/iwconfig ath0 txpower 0
Brian_E
DD-WRT Novice


Joined: 20 May 2012
Posts: 21

PostPosted: Mon Aug 06, 2012 11:54    Post subject: Re: Cron to reset in case of power failure Reply with quote
aceror wrote:


I guess you want this

*/30 * * * * root /sbin/ifconfig ath0 up

The command about runs every 30 min.


I just tried this, exactly as shown, but it didn't turn the wireless radio back on.
Brian_E
DD-WRT Novice


Joined: 20 May 2012
Posts: 21

PostPosted: Mon Aug 06, 2012 12:22    Post subject: Reply with quote
I've managed to get what I want by putting in the following cron jobs:-

0 6-22 * * * root /sbin/ifconfig ath0 up
5 6-22 * * * root /sbin/ifconfig ath0 up
10 6-22 * * * root /sbin/ifconfig ath0 up
15 6-22 * * * root /sbin/ifconfig ath0 up
20 6-22 * * * root /sbin/ifconfig ath0 up
25 6-22 * * * root /sbin/ifconfig ath0 up
30 6-22 * * * root /sbin/ifconfig ath0 up
35 6-22 * * * root /sbin/ifconfig ath0 up
40 6-22 * * * root /sbin/ifconfig ath0 up
45 6-22 * * * root /sbin/ifconfig ath0 up
50 6-22 * * * root /sbin/ifconfig ath0 up
55 6-22 * * * root /sbin/ifconfig ath0 up
0 23 * * * root /sbin/ifconfig ath0 down

This will turn wireless off at 11.00pm and on again at 6.00am. In addition, if there is a power failure between 6.00am and 10.00pm, wireless will switch back on within 5 minutes of the power being restored. However, if someone tries to switch the wireless signal back on after 10.00pm by rebooting the router, it won't come back on because I have a startup script that turns it off on bootup.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum