Make your PC wake you up

It’s a little known feature of a BIOS: You can set it to start the PC at a specified time and date, practically like an alarm clock. Even lesser known is the fact that you can set this same setting in Linux by writing a date and time to this special file (as root):

$ echo "+00-00-00 00:05:00" > /sys/class/rtc/rtc0/wakealarm

Now shutdown your PC. It should boot up again 5 minutes after you executed that line.

Let’s harness this awesome power and turn it into a poor man’s complex alarm clock:

  • sudo sh -c ‘echo “2008-05-24 06:59:00″ > /sys/class/rtc/rtc0/wakealarm’
  • Start a media-player and make it play a song
  • Quickly put your PC in hibernate

Now when your PC is booting in the morrow, it’ll return from hibernate and continue playing the song, waking you up in the process. Yay.

Update: Since kernel 2.6.22 (and Ubuntu Intrepid) the location of the alarm file has changed. I’ve updated the path, but if you’re using a kernel version lower, or an Ubuntu version older than these, you should echo to the file “/proc/acpi/alarm” instead of “/sys/class/rtc/rtc0/wakealarm“.

This entry was posted in Linux. Bookmark the permalink.

10 Responses to Make your PC wake you up

  1. David says:

    Of course, this only works if on your PC sound works after a hibernate, which on my PC it doesn’t, courtesy of Ubuntu Hardy.

    (It’s not all bad. Prior to Hardy, Hibernate/Suspend wouldn’t work at all)

    Alternatively one could use at, but maybe stuff like that is better reserved for a small script. I’ll be working on it.

  2. Cool, very cool!

    /me is thinking about a script that wakes my computer a 3 am to perform a backup, configure the next wake-up, and go back to sleep again.

    But for now, do you know why I have this?
    $ cat /proc/acpi/alarm
    2008-05-24 **:**:27

    Doesn’t change…

  3. David says:

    I have no idea :s

    You might want to try using this differint method, maybe it’ll do the trick: http://www.mythtv.org/wiki/index.php/ACPI_Wakeup#Using_.2Fsys.2Fclass.2Frtc.2Frtc0.2Fwakealarm

  4. Pingback: Linux Shutdown Management

  5. Pingback: Linux Shutdown Management « Tnoergaard’s Blog

  6. daniel says:

    bash: /proc/acpi/alarm: No such file or directory :(

  7. moped says:

    Always test the sorts and brakes of your scooters for sale you may be thinking of getting. It might just prevent your life.

  8. andrew says:

    Ubuntu 12.04.2 – kernel 3.2.0-38

    $ ls -l /sys/class/rtc/rtc0/wakealarm
    -rw-r–r– 1 root 4096 feb 14 10:07 /sys/class/rtc/rtc0/wakealarm

    $ sudo echo "+00-00-00 00:05:00" > /sys/class/rtc/rtc0/wakealarm
    bash: /sys/class/rtc/rtc0/wakealarm: Permission denied

    how is it possible?

  9. Nice features, IT is improving our standards of life

  10. pay day loan says:

    rgqpyo hdhkigs mbikwikqodx vmgrjiw fcpbczbli nyllfq

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">