Set Alarm to Automatically Power On Linux Computer

It’s no secret that you can make your computer “sleep” to considerably save energy or battery on laptops. A battery-powered device can spend many days in standby mode. The power draw in this state is incredibly low.

You can wake your computer at any time by pressing the power button or a key on your keyboard. But what if you want it to automatically wake up at a certain time? This can help you automate certain tasks – for example, to download something at 4AM when Internet speed may be much higher. With a bit of command-line magic, you can schedule your device to wake up, take some action and then go back to sleep again.

Besides waking up from standby, you may find it even more useful to completely shut down your computer and power on at certain times. Hibernation is also supported, but Linux systems that use proprietary drivers don’t always wake from hibernation properly.

Test If Your Computer Supports Wake-Up Timers

It’s possible that some computers don’t have the proper hardware to support this feature. However, on most configurations, this should work. You can do a quick test: open a terminal emulator and enter the following command.

Your computer should go to sleep and wake up thirty seconds later. If your device needs more than twenty seconds for standby, increase the wake-up time by changing “30” to a higher number.

Also, test if the computer supports waking up from a complete shutdown.

Regarding -m off, the command manual mentions: “Not officially supported by ACPI, but it usually works.”

If the kernel, drivers and hardware all get along with each other, you should have no problems. If the timers aren’t supported, it’s probably because the hardware and/or BIOS/UEFI configurations don’t meet the requirements. But you might as well try your luck and see if upgrading some drivers or switching from proprietary ones to open source does the trick. You can also try to install a newer kernel.

As previously mentioned, hibernation has issues non-related to the rtcwake command. It does work most of the time but also fails on occasion. When it fails, your screen will remain black or show you an error message.

How to Use the rtcwake Command

The basic use of the command is simple: pick a power-saving method and a time when to wake up. In the previous command the -s parameter was used to specify how many seconds to wait before powering back on. But usually you will want to specify an absolute time, like 9AM tomorrow morning. For that, you use the --date parameter instead of -s.

rtcwake Date Parameter

Note: not all hardware supports setting wake up dates far into the future. This is something that you’ll just have to test to see if it works for your specific device.

Time specification is in 24-hour format. Here’s a relevant screenshot of the command manual with different options for setting the time and date of a wake-up event.

rtcwake-time-date-specification

“YYYY-MM-DD hh:mm” means, year, month, day, hour and minute – for example: --date 2020-02-28 15:00 for the 28th of February, year 2020, 3PM.

rtcwake Dry Run

You can add another parameter to rtcwake, -n, to display when the alarm will be set.

This is a “dry run,” meaning it doesn’t actually set an alarm and only “pretends” to do it. It’s useful to add -n when you want to test if your date specification is correct. Once you’re sure it’s right, just use the command without -n to set the actual wake-up time.

rtcwake Power-Saving Methods

The relevant options you can pass to the -m parameter are:

  • -m mem – normal standby mode you’re familiar with from the shutdown menu.
  • -m disk – hibernate mode that saves memory content to storage device. Not recommended when using proprietary drivers.
  • -m off – normal shutdown.
  • -m disable – cancel a wake-up event you previously set.
  • -m no – don’t power off or standby, just set a wake event. For example, you can set a wake-up time for tomorrow morning, then continue to work on your computer. When you’re done, shut down normally, and the device will automatically power on in the morning.
  • -m show – show wake-up events (previously-set alarms) currently active.

Conclusion

It’s up to you to find creative ways to use rtcwake. As a starter, this can help you find the computer fully booted in the morning. This way you skip the boring boot process which can take more than a minute on some systems. You could also install an utility, such as at, to automate tasks that your computer can run after waking up. We might even explore that option in a future tutorial.

4 comments

  1. To match the title and the article contents, the title should be “Set Alarm to Automatically Wake Up a Linux Computer” because that is what the article is talking about. ANY computer can be scheduled to POWER UP at the same time just by setting the proper BIOS/UEFI configuration options.

  2. Génial! It works on my old ACER Aspire 5738Z laptop! I will use soon.

  3. If I do sudo rtcwake -m no mem –date 20190208031500, wanting the computer to wake from suspend at 3:15 am local (utc -10) it actually wants to wake up at 1:30 pm local. How to get it to wake up at 03:15 local?

    1. ” rtcwake -m no mem” should be ” rtcwake -m no” or ” rtcwake -m mem”, not “no” and “mem” at the same time. But I assume you used the correct command and probably just made a mistake in this comment.

      I never had this problem since rtcwake can check and see if clock is UTC or Local. So I’m just giving you theory here. The manual says about these two options. See if one of them does the trick:

      -l | –local
      Assumes that the hardware clock is set to local time, regardless of the contents of /etc/adjtime.
      -u | –utc
      Assumes that the hardware clock is set to UTC (Universal Time Coordinated), regardless of the contents of /etc/adjtime.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.