I have VM with Ubuntu 16.04.1 LTS, and time is wrong. The difference is about 15 hours. I synchronize it via
sudo ntpdate 1.ro.pool.ntp.orgevery day and then it becomes right, but next day I have this problem again.
The VM is following the virtualization host time that is wrong. Whist you are able to set it up, to the current time, with occasional
ntpdate commands, it will diverge rather quickly to the host time again, as you are witnessing.
To fix the time, you can either:
fix the host/hypervisor time and setup NTP properly on the hypervisor (it is recommended to do it nonetheless to keep all the infra-structure/logs on the same time);
tell the VM to not follow the host time without running a time synchronization daemon (nonetheless there is the phenomenon of time compression, and time will slowly diverge from the official time after the
tell the VM to not follow the host time and run an NTP synchronization daemon
Option 2 is not a desired setup, but I included it to illustrate a point. I have followed option 1 once in a while with very light VM setups, however Option 3 is the course of action recommended by VMWare white papers.
Assuming a VMware host, For disabling the syncronization with the vmware host, you have to have (open) vmtools installed, and run upon boot, as root or with sudo:
vmware-toolbox-cmd timesync disable
And then to install a NTP daemon, you can either install
ntpd, or the
Nevertheless, I would also stress again, that from an operational point of view, it is also advisable that the virtualization host machine has the time/NTP configuration fixed.
See also this post from our sister site ServerFault Do I need to run a NTP server in every VM?
It should be noted that time not only "can" drift away, but will drift away due to the fact that intervals between timer interrupts (which timekeeping on OS is often based on) are stretched and compressed as the hypervisor would see fit.