rtcwake

systemLinux
The rtcwake command is one of the most frequently used commands in Linux/Unix-like operating systems. rtcwake Enter a system sleep state until specified wakeup time

Quick Reference

Command Name:

rtcwake

Category:

system

Platform:

Linux

Basic Usage:

rtcwake [options] [arguments]

Common Use Cases

    Syntax

    rtcwake [options]

    Options

    Option Description
    -a, --auto Automatically detect the RTC device
    -d, --device=DEV Specify the RTC device (e.g., /dev/rtc0)
    -l, --local RTC uses local time instead of UTC
    -m, --mode=MODE Suspend mode: standby, mem, disk, freeze, off, on, no, disable, show
    -n, --dry-run Don't set the alarm, only show what would happen
    -s, --seconds=SEC Set the RTC alarm SEC seconds from now
    -t, --time=TIME Set the RTC alarm to absolute time (seconds since epoch)
    --date=DATE Set the RTC alarm to a date-time string in format: YYYY-MM-DD hh:mm:ss
    -v, --verbose Be verbose about what is being done
    -h, --help Display help message and exit
    -V, --version Output version information and exit

    Examples

    How to Use These Examples

    The examples below show common ways to use the rtcwake command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    sudo rtcwake -m mem -s 3600
    Suspend the system to RAM for 1 hour (3600 seconds).
    sudo rtcwake -m disk -s 1800
    Hibernate the system for 30 minutes (1800 seconds).
    # Advanced Examples Advanced
    sudo rtcwake -m freeze -t $(date -d 'tomorrow 08:00' +%s) Freeze the system until 8:00 AM tomorrow. sudo rtcwake -m no -s 60 -v Don't suspend but set RTC wakeup time for 60 seconds from now (verbose output). sudo rtcwake -m mem -s 600 --date 20:30 Suspend the system to RAM until 8:30 PM today. sudo rtcwake -m disk -s 0 -a Hibernate immediately and automatically detect the RTC device. sudo rtcwake -m mem -d /dev/rtc1 -s 300 Suspend to RAM for 5 minutes using the specified RTC device. sudo rtcwake -m on -s 3600 Just set the wakeup time, but don't suspend the system. sudo rtcwake -m standby -s 1800 --local Suspend to standby for 30 minutes, using local time for calculations. sudo rtcwake -m mem -s 600 && reboot Suspend the system for 10 minutes, then reboot after waking up.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The `rtcwake` command is a Linux utility that allows users to put the system into a suspended state and automatically wake it up at a specified time. It uses the Real-Time Clock (RTC) hardware, which is powered even when the system is suspended or powered off, to trigger the wake-up event. This command is particularly useful for scheduling system maintenance tasks, periodic checks, or simply for energy conservation by suspending systems during periods of inactivity. It's part of the util-linux package and is available on most Linux distributions. Key features of the `rtcwake` command include: 1. Multiple Sleep States: Supports various system sleep states such as: - `standby` (Power-On Suspend): Lowest power saving, fastest resume - `mem` (Suspend-to-RAM): Greater power saving, quick resume - `disk` (Suspend-to-Disk/Hibernate): Highest power saving, slowest resume - `freeze` (Suspend-to-Idle): CPU is idle but everything else runs normally - `off` (Poweroff): Completely shut down but wake up at the specified time 2. Flexible Timing Options: Allows setting wake-up times as: - Seconds from now - Absolute time (in Unix timestamp format) - Date-time string in human-readable format 3. RTC Device Selection: Can work with different RTC devices if multiple are present in the system. 4. Dry Run Mode: Allows testing the wake-up configuration without actually suspending the system. 5. Local or UTC Time: Can work with RTC clocks set to either UTC or local time. Common use cases for `rtcwake` include: - Scheduling system backups during off-hours - Energy-saving measures for servers with predictable usage patterns - Automated system updates at specific times - Starting recording devices at predetermined times - Home automation systems that need to wake up periodically It's important to note that `rtcwake` requires root privileges (via sudo or as the root user) because it needs direct access to system hardware and the ability to change system power states. Additionally, not all hardware supports all sleep states, so it's advisable to test the desired sleep mode before relying on it for critical operations. The command can be combined with other Linux utilities and scripts to create sophisticated power management solutions that balance energy efficiency with system availability.

    Related Commands

    These commands are frequently used alongside rtcwake or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the rtcwake command works in different scenarios.

    $ rtcwake
    View All Commands