GeodSoft logo   GeodSoft

Computer Time Synchronization
A Beginner's Guide to Network Time Protocol (NTP)

Warning! This page may contain obsolete information.

Installing NTP on Unix

Setting up an NTP server is actually quite simple, at least if you have the right operating system(s). Given the ease with which I installed it on both Linux and OpenBSD systems, I suspect "right" means any recent open source Unix like system with the GNU development tools installed. Installing the binary version of the NT product is just as easy. Since I haven't done installs on other system's I have no way of knowing if others will be as easy. Hints has OS specific install notes supplied by various persons who've installed NTP. Many are old and no accuracy is guaranteed.

The actual steps to do a basic install on Unix systems are as follows. For full instructions see Building and Installing the Distribution. Get a recent source package from the NTP download page. cd to one directory above where you plan to make the software. I typically use /usr/local/tools and untar the source package into your working directory such as /usr/local/tools/ntp-4.0.99k. If you have GNU tar

tar -zxvf tarfile

(where tarfile is the complete path and filename to wherever you saved the downloaded source package) will work. The z option is for uncompressing a .gz or .tgz file. Then cd to the newly created directory such as ntp-4.0.99k and type:

.  ./configure



On systems using gcc, lots of warnings will scroll by. Then if you want to install the binaries into the default install directory, /usr/local/bin, type:

make install

If you want a different install directory for the executables, you'll need to edit the install script. If your install is successful, you'll be able to run ntptrace to help you select public NTP servers to use as your time sources.

You could start ntpd with only command line options but you'll want to create a configuration file, typically ntp.conf. The simplest configuration file is:

server servername

where servername is the public NTP server that you are using as a time source. Names or IP addresses will work but names are preferred as the IP addresses are much more likely to change than the names which are often aliases such as ntp.some-, chosen to indicate an NTP server. Ntpd will work with a single time source but for accuracy you should add two or more public NTP servers as discussed previously. If you're going to run multiple coordinated NTP servers as recommend, you'll be adding "peer servername" lines as you bring other NTP servers online. You'll also want to include:

driftfile /etc/ntp.drift

so ntpd will save the calculated drift and not have to recompute it from scratch each time it restarts. You could pick another location but /etc/ntp.drift is the usual location.

I started ntpd for the first time with the following command:

ntpd -A -c /etc/ntp.conf -l /var/log/ntp.log

By default, ntpd runs with encrypted authentication enabled. The "-A" turns it off. Only a few of the public servers list the authentication options and figuring out how to set up the keys is simply more than I'm prepared to deal with at this time. I didn't want to troubleshoot possible failures if authentication was left on, so I turned it off. The -c to specify the configuration file is probably not necessary when using the default location but it's easier to put in than to try to figure out what's wrong if it is required. I used the -l to specify an NTP specific log rather than the default system log. I wanted to see what NTP was doing without digging through a lot of other messages. It's good that I did because I misspelled driftfile in one of the configuration files and would probably not have known this otherwise.

About four minutes after starting with three carefully selected public NTP servers, ntpd adjusted my Linux computer (first installed) clock by -11.605842 seconds. I used The Official U.S. Time page as a check. This Java application shows the official U.S. time and indicates the accuracy which has been between 0.2 and 0.8 seconds when I've used it. This should be much less accurate than NTP using multiple time sources but prior to NTP it's the most accurate time source I've found. It serves as a check and verifies that NTP is actually working. I watch the clock with "date" keyed in on the command line and press Enter when the clock hits any time that the seconds end with zero. Since NTP synchronized the Linux clock, the times have always matched to the second.

After verifying that all my computer clocks are synchronized with each other and stay that way and also appear accurate, I added the command line above to each rc.local file. ntpd has a huge number of options and capabilities that have not even been mentioned here. After you have it working in a very basic mode such as described here you may wish to study the other options described in the man pages and other documentation at the University of Delaware site.

transparent spacer

Top of Page - Site Map

Copyright © 2000 - 2014 by George Shaffer. This material may be distributed only subject to the terms and conditions set forth in (or These terms are subject to change. Distribution is subject to the current terms, or at the choice of the distributor, those in an earlier, digitally signed electronic copy of (or cgi-bin/ from the time of the distribution. Distribution of substantively modified versions of GeodSoft content is prohibited without the explicit written permission of George Shaffer. Distribution of the work or derivatives of the work, in whole or in part, for commercial purposes is prohibited unless prior written permission is obtained from George Shaffer. Distribution in accordance with these terms, for unrestricted and uncompensated public access, non profit, or internal company use is allowed.

Home >
How-To >
Introduction to NTP >

What's New
Email address

Copyright © 2000-2014, George Shaffer. Terms and Conditions of Use.