0

I have a problem with synchronize time after the Suspend and Power On, after a while.

For show purposes I prepared the following test:

  1. Lets say I have 01:43 Local Time, 21:43 Universal/RTC Time. Right here everything is ok. The following commands are called: hwclock and timedatectl status

Screen 1: Shows the time before the VM is suspended

  1. Now I can do procedure of Suspend + Unregister my VM, for about 20 minutes.

Screen 2: VSphere Client Suspend VM + Unregister VM

  1. After approximately 20 minutes, we can re-register and power up the VM. After executing hwclock and timedatectl status commands again, we can see some difference. The hwclock command shows the correct time - 20 minutes have passed. In addition, it includes +4 of local time.

Screen 3: Shows the time after the VM started again (Register & Power On)

However, with the timedatectl command we can observe the correct RTC time (taken probably from the hardware time) while Local and Universal Time remained at the stage of Suspending and "Starting" VM.


I checked the .vmx file, there is no time synchronization entry. Another effect - after restarting, of course, the time is set correctly.

In order to synchronize the time correctly it is enough that I do the follow operations and the time is correct:

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start

However, I cannot do this every time a machine is suspended and then powered on.

Is it possible to do this operation from time to time - check the ntp time from the server and update it if necessary? I don't want to perform cron every 5 minutes. This seems to me to be a weak solution.


EDIT: It seems that after X minutes (about 8?), the automatic time synchronization has taken place. Is it enough that I installed ntp earlier? (sudo apt-get install ntp) and once I did this procedure with sudo ntpd -gq?

Is it possible to set how often the synchronization should do job?

Screen 4: Synchronization confirmation


IMPORTANT

EDIT 2: If the machine was stopped longer (10 hours), the time did not synchronize with the server. Only the local time has replaced the RTC time... Any advice?

EDIT 3: For now I'll set CRON to do job every 10 min.

*/10 * * * * /usr/sbnin/ntpd -gq 2>&1 >/dev/null

But I'm not sure about this solution. The only one that works so far.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.