rtcwake linux command


This tip is beyond any formal Linux Training.

Want to hibernate your Linux machine automatically or want to start it automatically at a specified time to start some process?
Please welcome – rtcwake command.

You can use this command to either hibernate it now and wake up your Linux machine at a specific time.

Or you can use it to wake it up after hibernating it at your will (read time) but want the machine to start at a specific time.

This can be handy if you want your computer to do something at a specific time, but don’t want it running 24/7.

STEP #1. Install the rtcwake ( i am doing it on ubuntu)
sudo apt-get install rtcwake

EXAMPLE #1. Hibernate your machine now, and start it after 35 seconds, saving the disk contents.
sudo rtcwake -m disk -s 35

EXAMPLE #2. Keep on working right now, but once I hibernate at my will. Start the machine again at 1000 hours tomorrow.
sudo rtcwake -m no -l -t $(date +%s -d ‘tomorrow 10:00’)

As per the man pages of rtcwake, here are some more details that can help.

Types of Suspend. The -m switch accepts the following types of suspend:

standby – Standby offers little power savings, but restoring to a running system is very quick. This is the default mode if you omit the -m switch.
mem – Suspend to RAM. This offers significant power savings – everything is put into a low-power state, except your RAM. The contents of your memory are preserved.
disk – Suspend to disk. The contents of your memory are written to disk and your computer is powered off. The computer will turn on and its state will be restored when the timer completes.
off – Turn the computer off completely. rtcwake’s man page notes that restoring from “off” isn’t officially supported by the ACPI specification, but this works with many computers anyway.
no – Don’t suspend the computer immediately, just set the wakeup time. For example, you could tell your computer to wake up at 6am. After that, can put it to sleep manually at 11pm or 1am – either way, it will wake up at 6am.

The -s option takes a number of seconds in the future. For example, -s 35 wakes your computer up in 35 seconds.

The -t option allows you to wake your computer up at a specific time. To easily provide the correct number of seconds, combine the date command with the rtcwake command.
The -l switch tells rtcwake that the hardware clock is set to local time, while the -u switch tells rtcwake that the hardware clock (in your computer’s BIOS) is set to UTC time. Linux distributions often set your hardware clock to UTC time and translate that to your local time.

Here is small illustration from my machine.

rtcwake command linux

rtcwake command linux