Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Can the pmset bash command be used with more than one repeating action pair?

For example:

Wake or Power on at 13:00, Sleep at 17:00


Wake at 18:00, Shutdown at 20:00

If not, is there an open-source tool that can accomplish this? Is there another tool that can turn on a computer at a certain time or is this only possible in pmset?

EDIT: I am looking for a tool that will work on all UNIX-like systems in bash.

share|improve this question
up vote 0 down vote accepted

You can use rtcwake and shutdown to do that.

rtcwake is a utility to suspend the computer and wake it up after a certain period of time. The basic usage is

rtcwake -m <mode> -s <seconds>

For example

rtcwake -m mem -s 60

will suspend the computer to ram and wake it up after 60 seconds. It is possible to write scripts to invoke the desired actions in sequence, for example:


# calculate seconds remaining until $1
seconds_until() {
    current_time=`date +%s`
    target_time=`date -d $1 +%s`
    seconds=`expr $target_time - $current_time`
    # wrap seconds
    [ $seconds -lt 0 ] && seconds=`perl -e "print $seconds+86400"`
    echo $seconds

# suspend and wake up at 13:00
rtcwake -m mem -s `seconds_until 13:00`

# wait until 17:00, suspend, and wake up at 18:00
sleep `seconds_until 17:00`
rtcwake -m mem -s `seconds_until 18:00`

# wait until 20:00 and shutdown
sleep `seconds_until 20:00`
shutdown -h now

Root privilege is required to use rtcwake.

share|improve this answer
Does this work in all unix-like systems? See edit. – Blue Ice Mar 28 '13 at 14:14

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.