Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

How can I suspend from the command line for a pre-determined amount of time?

For example, in the terminal i can do "pm-suspend", and that suspends the computer.
But I want the computer to come out of this suspend a couple of days later, on its own, and I don't know how to do that.

share|improve this question
Can you give an example about what you mean by 'suspend'? I have a response but I wanted to make sure I understand your question before posting. – ruffEdgz Feb 28 '12 at 19:28
suspend is a computer state in which the computer spends incredibly little amount of energy while retaining some sort of power. – Hermann Ingjaldsson Feb 28 '12 at 20:39
up vote 4 down vote accepted

I'm assuming that you want Suspend-to-RAM (ACPI S3).

Here is what works for me.

sudo rtcwake --verbose  --mode mem --time `date '+%s' -d '+ 130 minutes'`

The subcommand passed as the argument to --time is the easy way to generate the int timestamp required by that argument.

Note that on my system, I have to cheat a bit: the command above just suspends for 10 minute -- must be related to the internal clock not using UTC.

Note also that --mode can take other values:

  • disk to Suspend-to-disk (ACPI S4)
  • no to just set the alarm but does not suspend
  • (there are other options, see man rtcwake)

If you use no, you can then check the state of the alarm with

cat /proc/driver/rtc

Look at the first 6 lines:

rtc_time     : 10:34:45
rtc_date     : 2012-02-29
alrm_time    : 10:44:36
alrm_date    : 2012-02-29
alarm_IRQ    : yes
alrm_pending : no

alrm_pending always display no for me, go figure... But the interesting one is the alarm_IRQ, which is set to yes when an alarm is set.

share|improve this answer
to suspend for 20 seconds: rtcwake -m mem -s 20 – Hermann Ingjaldsson Feb 29 '12 at 11:26
Adding -l or --local to @Pierre-Antoine's rtcwake command makes the command work correctly and sleep for the expected amount of time. – Scott Severance Feb 29 '12 at 20:19
@ScottSeverance: -l typically would work for dual-boot systems, since Windows requires the RTC to be set to local time; there's no reason not to have the RTC set to UTC when using only Linux. – ΤΖΩΤΖΙΟΥ Sep 17 '12 at 14:33

Your Answer


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.