Last Updated : 10 Oct, 2024
hwclock also called Real Time Clock (RTC), is a utility for accessing the hardware clock. The hardware clock is independent of the OS(operating system) you use and works even when the machine is shut down. The hardware clock is also called a BIOS clock. A user can also change the date and time of the hardware clock from the BIOS.
The hardware clock stores the values of the second, minute, hour, day, month, and year. The hwclock utility saves its settings in the "/etc/adjtime" file, which is created when a user makes the first change.
Syntaxhwclock [function] [option...]Key Functions of the hwclock Command 1. -r, --show
Displays the current time stored in the hardware clock (RTC).
Example:
sudo hwclock -r2. --get
Displays the drift-corrected RTC time.
Example:
sudo hwclock --get3. --set
Sets the hardware clock to a specified date and time. You must provide the date using the --date option.
Example:
sudo hwclock --set --date="2024-10-10 15:45:00"4. -s, --hctosys
Syncs the system time to match the hardware clock.
Example:
sudo hwclock -s5. -w, --systohc
Updates the hardware clock to match the system clock. This is the reverse of --hctosys.
Example:
sudo hwclock -w6. --systz
Sends the timescale configurations (like UTC or local time) to the kernel.
7. -a, --adjustAdjusts the hardware clock to account for systematic drift based on the drift information stored in the "/etc/adjtime" file.
8. --predictPredicts the drift-adjusted RTC time based on the given date.
Common Options in the hwclock Command Option Description-u, --utc
Shows that the RTC (Real Time Clock) timescale is set to UTC. -l, --localtime
Shows that the RTC timescale is set to Local Time. -D, --debug
Displays detailed debug information based on the demands of the hwclock
command. -V, --version
Displays the version information of the hwclock
utility and exits. -h, --help
Displays a help text with an overview of the available options and exits the command.
Examples of Using the hwclock Command 1. To display the Hardware Clock Date and Time: 2. Using adjust function: 3. Using debug option to get the debug information: ConclusionNote: You should run the hwclock command with sudo privileges to make changes to the hardware clock or view the current RTC time.
The hwclock utility is an essential tool for managing hardware clock settings in Linux. If you're adjusting for drift, syncing system time, or simply checking the current RTC time, mastering the hwclock command can help you maintain accurate and reliable timekeeping on your Linux machine. With easy-to-use functions and options, it's a must-know utility for any Linux user or system administrator.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4