Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 down vote accepted

MarcusJuniusBrutus, 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .