Make your PC wake you up

Published on .

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”.

David Verhasselt

Senior full-stack engineer with 5 years of experience building web applications for clients all over the world.

Interested in working together?

Find out what I can do for you or get in touch!

Like this? Sign up to get regular updates