17.18. Configuring the Hardware Clock Update

The system clock can be used to update the hardware clock, also known as the real-time clock (RTC). This section shows three approaches to the task:
Instant one-time update
To perform an instant one-time update of the hardware clock, run this command as root:
~]# hwclock --systohc
Update on every boot
To make the hardware clock update on every boot after executing the ntpdate synchronization utility, do the following:
  1. Add the following line to the /etc/sysconfig/ntpdate file:
    SYNC_HWCLOCK=yes
  2. Enable the ntpdate service as root:
    ~]# systemctl enable ntpdate.service
Note that the ntpdate service uses the NTP servers defined in the /etc/ntp/step-tickers file.

Note

On virtual machines, the hardware clock will be updated on the next boot of the host machine, not of the virtual machine.
Update via NTP
You can make the hardware clock update every time the system clock is updated by the ntpd or chronyd service:
Start the ntpd service as root:
~]# systemctl start ntpd.service
To make the behavior persistent across boots, make the service start automatically at the boot time:
~]# systemctl enable ntpd.service
or
Start the chronyd service as root:
~]# systemctl start chronyd.service
To make the behavior persistent across boots, make the service start automatically at the boot time:
~]# systemctl enable chronyd.service
As a result, every time the system clock is synchronized by ntpd or chronyd, the kernel automatically updates the hardware clock in 11 minutes.

Warning

This approach might not always work because the above mentioned 11-minute mode is not always enabled. As a consequence, the hardware clock does not necessarily get updated on the system clock update.
To check the synchronization of the software clock with the hardware clock, use the ntpdc -c kerninfo or the ntptime command as root:
~]# ntpdc -c kerninfo
The result may look like this:


pll offset:           0 s
pll frequency:        0.000 ppm
maximum error:        8.0185 s
estimated error:      0 s
status: 2001 pll nano
pll time constant:    6
precision:            1e-09 s
frequency tolerance:  500 ppm

or
~]# ntptime
The result may look like this:


ntp_gettime() returns code 0 (OK)
  time dcba5798.c3dfe2e0  Mon, May  8 2017 11:34:00.765, (.765135199),
  maximum error 8010000 us, estimated error 0 us, TAI offset 0
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset 0.000 us, frequency 0.000 ppm, interval 1 s,
  maximum error 8010000 us, estimated error 0 us,
status 0x2001 (PLL,NANO),
  time constant 6, precision 0.001 us, tolerance 500 ppm,
To recognize whether the software clock is synchronized with the hardware clock, see the status line in the output (highlighted).
If the third digit from the end is 4, the software clock is not synchronized with the hardware clock.
status 0x2401
If the second digit of the last four digits is not 4, the software clock is synchronized with the hardware clock.
status 0x2001