rtcwake in a cron job

Phil phil_lor at bigpond.com
Fri Aug 2 06:05:13 UTC 2013


On 02/08/13 14:33, Nils Kassube wrote:
> Phil wrote:
>> Thank you for reading this.
>>
>> I'm attempting to wake my computer from hibernation when a cron job is
>> activated.
>>
>> I've simplified the shell script as follows:
>>
>> #!/bin/bash
>> now=$(date +%s)
>> rtcwake -m no -t now
>
> That last line should be:
>
> rtcwake -m no -t $now
>
> But I doubt that it would work. AIUI, there are no processes running,
> while the machine is suspended and therefore you can't use cron to wake
> up the machine. Instead you should schedule a wakeup time before you
> suspend the machine.
>

Thanks yet again Nils for answering my questions.

I've discovered a solution.

Setting an awake time in rtcwake defeats the purpose of a cron job but a 
cron job will automatically run once the computer is manually woken at 
some random time after the cron job should have run. Cron then runs 
rtcwake to activate a second script after a pre-set time.

What I'm doing is setting various cron jobs to control a garden 
irrigation system. The cron job now turns on the irrigation and instead 
of cron turning it off again at a specified time I use rtcwake to turn 
it off after an elapsed time period. Not as convenient as cron but 
workable, I think.

-- 
Regards,
Phil




More information about the ubuntu-users mailing list