
A Linux system has two clocks:
- Hardware clock
- System clock
The hardware clock is always running, even when the operating system is shut down. If the system is powered off, the hardware clock continues to run from battery. The system clock only runs when the system is powered on. During boot, the system clock gets time from the hardware clock.
View date and time
The hwclock command without any options can be used to display the current date and time of the hardware clock.
[root@server1 ~]# hwclock
Sun 09 Apr 2017 01:48:48 PM CDT -0.689766 seconds
The -r or --show options will also show the current date and time of the hardware clock.
[root@server1 ~]# hwclock -r
Sun 09 Apr 2017 01:48:48 PM CDT -0.689766 seconds
The date command without any options can be used to display the current date and time of the system clock.
[root@server1 ~]# date
Sat Nov 14 12:32:00 CST 2016
Change date and time
The --set and --date options can be used to set the hardware clock.
[root@server1 ~]# hwclock --set --date "dd mmm yyyy HH:MM"
The --UTC or --localtime options can be appeneded to set the date and time to UTC or localtime.
[root@server1 ~]# hwclock --set --date "dd mmm yyyy HH:MM" --utc
[root@server1 ~]# hwclock --set --date "dd mmm yyyy HH:MM" --localtime
Sync hardware clock and system clock
If the hardware clock and system clock are not in sync, the clocks can be synchronized. Use the -s or --hctosys option to synchronize the hardware clock to the system clock.
[root@server1 ~]# hwclock --hctosys
Use the -w or --systohc option to sychronize the system clock to the hardware clock.
[root@server1 ~]# hwclock --systohc
Did you find this article helpful?
If so, consider buying me a coffee over at