I have a problem with synchronize time after the Suspend and Power On, after a while.
For show purposes I prepared the following test:
- Lets say I have 01:43 Local Time, 21:43 Universal/RTC Time. Right
here everything is ok. The following commands are called:
- Now I can do procedure of Suspend + Unregister my VM, for about 20 minutes.
- After approximately 20 minutes, we can re-register and power up the VM. After executing
timedatectl statuscommands again, we can see some difference. The
hwclockcommand shows the correct time - 20 minutes have passed. In addition, it includes +4 of local time.
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?
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.