Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Ubuntu precise. Is there a way to have scheduled cron jobs run even when Ubuntu is suspended? Perhaps some way to automatically wake up the system so a scheduled cron job can proceed and then put it back in suspension?

share|improve this question
    
Since the BIOS seems to only remember one wakeup at a time, you would need something besides cron, to avoid coordination problems. You need a tool that runs when the system is woken up, executes the background job, waits for it to finish, schedules the next wakeup, and put the system back to sleep. Sounds doable, but I haven't seen it implemented anywhere. –  Isaac Rabinovitch Sep 23 '12 at 1:44

1 Answer 1

up vote 2 down vote accepted

Menelae, the tool you are looking for is called rtcwake. It allows you to suspend your system and specify a specific wake up time. You can set up a few cronjobs, one to put the machine to sleep using rtwake to turn it on again in time for the second cron.

I found a nice example here:

If I wanted my machine to sleep overnight, wake for a short maintenance, go to sleep again and wake early in the morning, I would have four crons running. The first, to synchronize the OS clock with UTC (via ntp). The second, to synchronize hardware clock with UTC. The third, to put the machine to sleep every evening, using rtcwake and specify the exact moment when it should wake up later. The fourth cron would run a few minutes after the machine wakes and do whatever needs to be done. After all the tasks are complete, it would sleep the machine once more and make it wake up in the morning.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.