Fixing incorrect clock times on your Centos Virtual Machines
So recently I was plagued with a frustrating issue where the system clock of a virtual machine would only ever be correct after syncing with NTP, After a reboot the system would go back to being 12 hours behind, regardless of the UTC setting, Here is how I fixed it.
Note: All machines in this post are running CentOS 6.4
First step was to check UTC was actually set, which required UTC=true to be present in /etc/sysconfig/clock
Now, after much googling, the /etc/adjtime file can cause all sorts of havoc if incorrectly set up.
So we delete it and regenerate it.
rm -f /etc/adjtime ; hwclock --systohc --utc -D
What this command does is deletes the adjtime file, then sets the hardware clock to the system clock, adjusting for UTC, this hwclock command will also regenerate the adjtime file correctly.
After which we reboot, sync with NTP to make sure our time is spot on, and that's that!
R















