Posted: Sun Aug 05, 2012 13:20 Post subject: Cron to reset in case of power failure
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:-
Posted: Sun Aug 05, 2012 23:59 Post subject: Re: Cron to reset in case of power failure
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:-
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:-
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.