hwclock
Manage the hardware clock
TLDR
Display the current time as reported by the hardware clock
Write the current software clock time to the hardware clock (sometimes used during system setup)
Write the current hardware clock time to the software clock
SYNOPSIS
hwclock [function] [options]
PARAMETERS
--adjust
Add or subtract to the hardware clock the amount of time since the last time the clock was set or adjusted.
--hctosys
Set the system time from the hardware clock.
--systohc
Set the hardware clock from the system time.
--show
Display the hardware clock time.
--set --date=
Set the hardware clock to the specified date and time. Be careful with date format and the timezone.
--utc
Indicate that the hardware clock is set to UTC.
--localtime
Indicate that the hardware clock is set to Local Time.
--test
Do everything, except actually update the hardware clock.
--version
Display version information.
--help
Display help text and exit.
--directisa
Access the hardware clock directly, bypassing the kernel driver. (Older systems).
DESCRIPTION
The hwclock command is used to access and manipulate the hardware clock (RTC - Real Time Clock) in Linux systems. This clock is independent of the system clock and keeps track of time even when the system is powered off. hwclock can be used to display the hardware clock's time, set the hardware clock from the system clock, set the system clock from the hardware clock, and adjust the hardware clock based on the system's assumed time zone.
It's crucial for ensuring accurate timekeeping, especially in systems that are frequently powered off or disconnected from network time synchronization. The command interacts with a specific device file, usually `/dev/rtc0` or `/dev/hwrng`, representing the hardware clock. By default, hwclock operates in UTC. Proper use of hwclock is essential for maintaining consistent timekeeping across reboots and when dealing with dual-boot systems.
hwclock relies on the system's idea of what the hardware clock represents, which can be either UTC or local time. Misconfiguration can lead to time discrepancies.
CAVEATS
Incorrect use of hwclock can lead to time discrepancies, especially when the system and hardware clock time zones are not properly synchronized. Always double-check the RTC time zone setting (UTC or local) to avoid issues. Be cautious when setting the hardware clock time, as incorrect values can cause system-wide time problems.
TIME ZONE CONSIDERATIONS
The interpretation of the hardware clock time (UTC or local) is critical. If your hardware clock stores local time, you must use `--localtime`. If it stores UTC, use `--utc`. Mixing these up can lead to significant time errors.
DUAL-BOOT SYSTEMS
When dual-booting with operating systems like Windows, it's important to understand how each OS handles the hardware clock. Windows typically stores the hardware clock time in local time, while Linux often uses UTC. This mismatch can cause time synchronization issues when switching between operating systems. It's generally recommended to configure both OS to utilize UTC if possible, otherwise you might need custom scripts to set the time correctly on each boot.
ACCESSING HARDWARE CLOCK DEVICE
The hwclock command typically accesses the hardware clock via the `/dev/rtc` device. If this device is missing or inaccessible, hwclock may fail. In some cases, the device name might be different (e.g., `/dev/rtc0`). Proper permissions are needed to access this file, often requiring root privileges.
HISTORY
The hwclock command has been a standard utility in Linux systems for many years, predating more modern time synchronization methods like ntpd and systemd-timesyncd. Initially, it provided a way to manually manage the hardware clock, which was crucial for systems that lacked network connectivity or relied on the RTC for timekeeping across reboots. Over time, its usage has evolved as network time synchronization became more prevalent, but it remains a useful tool for diagnosing and manually correcting time-related issues and configuring RTC behavior.
SEE ALSO
date(1), timedatectl(1), ntpd(8)