← 返回命令列表

Linux command

hwclock 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Example

sudo hwclock

Example

sudo hwclock -w

Example

sudo hwclock -s

Set hardware clock

sudo hwclock --set --date="2025-01-15 14:30:00"

Example

sudo hwclock --systohc --utc

Example

sudo hwclock --systohc --localtime

说明

hwclock reads and sets the hardware clock (Real-Time Clock/RTC), which is a battery-backed clock that maintains time when the system is powered off. The hardware clock can be set to either UTC or local time. Linux systems typically use UTC for the hardware clock and convert to local time for display. Dual-boot systems with Windows may need the hardware clock in local time since Windows expects this. During boot, the system typically runs hwclock --hctosys to initialize system time from the hardware clock. NTP then corrects for any drift.

参数

-r, --show
Read and display hardware clock time
-w, --systohc
Set hardware clock from system time
-s, --hctosys
Set system time from hardware clock
--set --date=_TIME_
Set hardware clock to specified time
--localtime
Hardware clock is in local time
--utc
Hardware clock is in UTC
--adjust
Adjust for systematic drift
--verbose
Show detailed information about what hwclock is doing
--test
Dry run; show what would be done without modifying anything
-f, --rtc _FILE_
Use specified RTC device (default: /dev/rtc0)

FAQ

What is the hwclock command used for?

hwclock reads and sets the hardware clock (Real-Time Clock/RTC), which is a battery-backed clock that maintains time when the system is powered off. The hardware clock can be set to either UTC or local time. Linux systems typically use UTC for the hardware clock and convert to local time for display. Dual-boot systems with Windows may need the hardware clock in local time since Windows expects this. During boot, the system typically runs hwclock --hctosys to initialize system time from the hardware clock. NTP then corrects for any drift.

How do I run a basic hwclock example?

Run `sudo hwclock` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -r, --show do in hwclock?

Read and display hardware clock time