LinuxCommandLibrary

rtcwake

Wake system from sleep at specified time

TLDR

Show whether an alarm is set or not

$ sudo rtcwake [[-m|--mode]] show [[-v|--verbose]]
copy

Suspend to RAM and wakeup after 10 seconds
$ sudo rtcwake [[-m|--mode]] mem [[-s|--seconds]] [10]
copy

Suspend to disk (higher power saving) and wakeup 15 minutes later
$ sudo rtcwake [[-m|--mode]] disk --date +[15]min
copy

Freeze the system (more efficient than suspend-to-RAM but version 3.9 or newer of the Linux kernel is required) and wakeup at a given date and time
$ sudo rtcwake [[-m|--mode]] freeze --date [YYYYMMDDhhmm]
copy

Disable a previously set alarm
$ sudo rtcwake [[-m|--mode]] disable
copy

Perform a dry run to wakeup the computer at a given time. (Press to abort)
$ sudo rtcwake [[-m|--mode]] on --date [hh:ss]
copy

SYNOPSIS

rtcwake [options]

PARAMETERS

-d, --device dev
    Specifies the RTC device to use (e.g., rtc0). Defaults to rtc0 if not provided.

-m, --mode mode
    Sets the system sleep state. Valid options include standby, mem (suspend-to-RAM), disk (suspend-to-disk), off (shutdown), and no (do nothing, only set the alarm). Defaults to mem.

-s, --seconds seconds
    Sets the wake-up time to seconds from now.

-t, --time time
    Sets the wake-up time to the specified time. The time format is seconds since the epoch (1970-01-01 00:00:00 UTC).

-l, --local
    Indicates that the specified time is in the local timezone. Defaults to UTC.

-u, --utc
    Indicates that the specified time is in UTC (Coordinated Universal Time). This is the default.

-n, --dry-run
    Simulates the operation without actually setting the alarm or entering sleep state.

-v, --verbose
    Enables verbose output.

-V, --version
    Displays version information.

-h, --help
    Displays a help message.

DESCRIPTION

The rtcwake command is used to enter a system sleep state until a specified time. Upon waking, the system resumes where it left off. This tool utilizes the RTC (Real Time Clock) device and the system's power management features to achieve power savings. It allows users to set a specific time or a duration of time from the present to wake up the system. The program calculates the number of seconds until the target wake-up time and sets the RTC alarm to that value. The system is then instructed to enter a specified sleep state, such as suspend-to-RAM or suspend-to-disk. After the alarm triggers, the system automatically wakes up, providing a convenient and energy-efficient way to schedule tasks or simply reduce power consumption during idle periods. This utility is useful for tasks like unattended backups, scheduled maintenance, and simply turning on a computer at a certain time.

This command requires sufficient privileges to manipulate RTC and power management settings.

CAVEATS

The rtcwake command relies on the system's ability to correctly enter and exit sleep states. Not all hardware or kernel configurations support all sleep states. Ensure that the specified sleep state is compatible with the system before using rtcwake.

Improper use of this command could lead to data loss or system instability. Always test on a non-production system first.

System time changes after setting the RTC alarm might cause unexpected wake-up times.

RETURN CODES

Returns 0 on success, nonzero on failure.

POWER MANAGEMENT

The utility checks for necessary /sys/power/state support before executing any actions that lead to a sleep state.

SEE ALSO

sleep(1), shutdown(8), poweroff(8), reboot(8), hwclock(8)

Copied to clipboard