> ## Content Index
> Fetch the complete content index at: https://www.binarysludge.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Running ntp/ntpd on a development Virtual Machine (VM)
- URL: https://www.binarysludge.com/2011/10/31/running-ntpntpd-on-a-development-virtual-machine-vm/
- Published: 2011-10-31T23:42:36.000Z
- Updated: 2015-01-16T12:09:43.000Z
- Author: Andrew Martin
- Tags: error, Network Time Protocol, ntpd, system adminstration, system time, virtual machine, #Import 2026-10-22 12:56

![Big Ben](http://c213.r13.cf3.rackcdn.com/Big Ben.jpg "Top Marks") 

Keeping the system clock on the right time is troublesome for a virtual machine if VM guest tools are not available to synchronise clocks. As the guest OS does not have access to the hardware clock it relies on software to tick over its own clock, and inaccuracies generally lead to slowdown (although over-compensation for loss of timer ticks may gain time).

Changing any system's time can be risky - an OS relies on a contiguous series of time values. If a system event is scheduled to occur at a specified time and the clock is set forward beyond it, that time never occurs and the event will not occur.

Network Time Protocol (`ntpd`) avoids this problem by making minuscule adjustments to the clock frequency (the [slew](http://en.wikipedia.org/wiki/Slew?ref=binarysludge.com)), effectively shortening the length of a unit of time to the OS. `man ntpd` states:

> The slew rate of typical Unix kernels is limited to 0.5 ms/s, so for every second that the clock requires adjusting, 2000s are required to adjust it. 

For a development VM that is off for periods of time this slew rate is too slow, and if the machine doesn't run time-critical services `ntpd` can be configured to absolutely set the system time.

### What

- Synchronise clock of virtual machine using ntp

### Why

- Guest additions not available

### Risks

- Time-based system events not occurring

### How

1. Edit `/etc/sysconfig/ntpd` and add the `-x` flag (mine looks like this):  
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -x"  
On startup the ntpd daemon will set the time irrespective of how incorrect it currently is.
2. Add this line in the root `crontab` to refresh the time every 5 minutes.  

*/5 * * * * /sbin/service ntpd restart >> /tmp/ntpd.log 2>&1
  
Here is a [detailed explanation of Timekeeping in VMWare](http://www.vmware.com/files/pdf/Timekeeping-In-VirtualMachines.pdf?ref=binarysludge.com) and [What is a Reference Clock?](http://www.ntp.org/ntpfaq/NTP-s-algo.htm?ref=binarysludge.com#AEN1766) from [ntp.org](http://www.ntp.org/?ref=binarysludge.com)'s FAQ.