Time drifting when running a Linux guest under VMware ESX server, knows the way to solve time drifting problem easily.
The final working solution as of 27/03/2015:
NOTE: This method is now deprecated, correct settings in grub.conf and correct ntpd settings are all that is required for accurate time keeping. Please see:
https://www.vpsblocks.com.au/support/Knowledgebase/Article/View/71/0/solving-linux-time-drift
1. Uninstall or disable ntpd service
~# apt-get purge ntp -y
or
~# update-rc.d ntp disable
2. Create the directory /etc/clocksync if necessary
~# mkdir /etc/clocksync
3. Create script clocksyncsh as below:
#!/bin/bash ####################################### # SIMPLE BASH SCRIPT TO CONTROL DRIFT ####################################### # Copyright (c) Microsoft Corporation. # All Rights Reserved. ####################################### # Stop the NTP Daemon if [ -f /etc/redhat-release ] then service ntpd stop >> /dev/null 2>&1 else service ntp stop >> /dev/null 2>&1 fi # Force Sync first time with NTP server, replace with custom one if required ntpdate -s -b 0.au.pool.ntp.org # ntpdate -s -b 0.au.pool.ntp.org # Sync hw clock with System clock hwclock --systohc i=0 while true do # Keep Syncing system clock with h/w clock hwclock --hctosys # The time interval for which this script sleeps and force updates time sleep 150 i=`expr $i + 1` # Sync Hwclock against NTP after 60 sec if [ "$i" -eq 4 ]; then ntpdate -s -b 0.au.pool.ntp.org hwclock --systohc i=0 fi done
4. Make the script executable
~# chmod +x /etc/clocksync/clocksync.sh
5. Edit /etc/rc.local as below:
...
# By default this script does nothing.
/etc/clocksync/clocksync.sh &
exit 0
6. Edit the /etc/default/grub file as below:
...
GRUB_CMDLINE_LINUX_DEFAULT="clock=pit notsc divider=10"
...
7. Update the grub.
~# update-grub
8. Reboot the system.
~# reboot
|