1

I have a VM running Photon OS 3.0. NTP is not configured and it is using the hardware clock. It has fallen out of sync. The hardware clock hwclock is in sync with the hypervisor time, but when I run date it is not in sync with the hardware.

When I run timedatectl it is showing System clock synchronized: no

what is command/process to change this to System clock synchronized: yes

$ timedatectl
               Local time: Thu 2023-11-02 23:11:03 UTC
           Universal time: Thu 2023-11-02 23:11:03 UTC
                 RTC time: Thu 2023-11-02 23:09:29
                Time zone: UTC (UTC, +0000)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

2 Answers 2

2

If you want to copy the hwclock time into system time (= displayed by date), the most straightforward command to do that would be

hwclock --hctosys --utc --noadjfile

Note that this will change system time backwards, which can be bad for databases and other applications that care about the correct ordering of timestamps.

If you must make this change while applications are running, a safer way would be to use ntpdate -B <NTP server address> to gently "slide" the system clock to the correct time.

But any of the above will not change the System clock synchronized indication at all.


The System clock synchronized comes from the kernel's timekeeping status bits: when a NTP service is running and has successfully synchronized the system clock to a NTP time source, it will flip the appropriate bits in the kernel's time_status word using the adjtimex(2) system call. The System clock synchronized is a direct interpretation of the appropriate time_status bits by systemd-timedated.

In a regular Linux system, you technically could install the optional adjtimex utility and then use adjtimex -S 0 to set the kernel's time_status word manually to the state it would normally have when NTP synchronization is in effect; but I cannot recommend this because it would be effectively just lying to yourself and your system.

Also, it appears the Photon OS may not have the adjtimex command/package available for it anyway, so the practical answer might as well be "you cannot do it without configuring NTP."

2

Figured out what was causing it. The Synchronize Time with Host setting in vcenter was unchecked for some reason. Had it enabled and System clock synchronized setting changed to yes on the VM

Snapshot from Vcenter

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.