The simple method: ntpupdate
According to the Ubuntu docs, the time is checked against the ntp.ubunto.com time server and the system clock is updated. This can also be done manually at any time by running:
Documentation at https://help.ubuntu.com/7.10/server/C/NTP.html shows how to set this up as a daily chron job so that time is adjusted every 24 hours. I wanted a more robust method, that kept the clocks in sync continuously, without introducing a daily "jump".
The preferred method: ntpd
NTP stands for Network Time Protocol, and it is an Internet protocol used to synchronize the clocks of computers to some time reference. NTP is an Internet standard protocol originally developed by Professor David L. Mills at the University of Delaware. -- from the Overview of NTP at http://www.ntp.org/ntpfaq/NTP-s-def.htm
Run the ntpudate command to synch your clock before starting ntp. That way, the ntp process will have less intial adjusting to do.
Run the normal apt-get install. Note that the 7.10 documentation on https://help.ubuntu.com/7.10/server/C/NTP.html says to install ntp-simple. I strarted with that but got an error:
Package ntp-simple is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source. However the following packages replace it: ntp E: Package ntp-simple has no installation candidate
Here's the steps that worked:
astevens@ubi:~$ sudo apt-get install ntp
Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: ntp-doc The following NEW packages will be installed: ntp 0 upgraded, 1 newly installed, 0 to remove and 56 not upgraded. Need to get 0B/434kB of archives. After unpacking 1090kB of additional disk space will be used. Media change: please insert the disc labeled 'Ubuntu-Server 7.10 _Gutsy Gibbon_ - Release i386 (20071016)' in the drive '/cdrom/' and press enter
Put the CD in and press 'enter'.
Selecting previously deselected package ntp. (Reading database ... 30303 files and directories currently installed.) Unpacking ntp (from .../ntp_4.2.4p0+dfsg-1ubuntu2_i386.deb) ... Setting up ntp (1:4.2.4p0+dfsg-1ubuntu2) ... * Starting NTP server ntpd
Check that ntp is running
astevens@ubi:~$ ps ax | grep ntp
You should see this line in the list
23546 ? Ss 0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -u 106:114 -g
Everything will work fine without touching the configuration file, but the NTP Daemon will do no statistics logging and will use a single time server. To change these settings, edit the configuration file at:
To see what time server is being used:
astevens@ubi:~$ ntpq -p
remote refid st t when poll reach delay offset jitter ============================================================================== *europium.canoni 184.108.40.206 2 u 117 128 377 109.779 -4.454 4.942
I wanted loggin and a more robust time server set up.
Remove the comment on statsdir /var/log/ntpstats/
Set your time servers
Unless you have other preferences, use the servers from the NTP Pool Project at http://www.pool.ntp.org/
They provide a "big virtual cluster of timeservers striving to provide reliable easy to use NTP service for millions of clients without putting a strain on the big popular timeservers." Their website suggests various server configurations, depending on your location. In North America, they suggest the following:
server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org
I left the default ubuntu server at the 5th location.
Save the config file and restart the daemon.
astevens@ubi:~$ sudo /etc/init.d/ntp restart
* Stopping NTP server ntpd [ OK ] * Starting NTP server ntpd [ OK ]
You should now be able to see a larger set of servers:
astevens@ubi:~$ ntpq -p
remote refid st t when poll reach delay offset jitter ============================================================================== -host2.kingrst.c 220.127.116.11 2 u 35 64 377 45.713 -12.960 2.310 +18.104.22.168 22.214.171.124 2 u 39 64 377 87.107 -26.329 2.348 +zeus.yocum.org 126.96.36.199 2 u 33 64 377 25.027 -21.723 1.829 *ntp.your.org .CDMA. 1 u 32 64 377 35.484 -21.275 4.059 -europium.canoni 188.8.131.52 2 u 32 64 377 109.349 -7.479 2.871
Here, we have two hosts designated outliers (-), two as candidates (+) and one as the system peer (*). For details on ntpq, including other codes and what they mean, see: http://www.cis.udel.edu/~mills/ntp/html/ntpq.html
Installing the documentation
It's not strictly necessary, but NTP does not include man pages or much help, so I went ahead and installed the html docs:
astevens@ubi:~$ sudo apt-get install ntp-doc
The html files for ntp and ntpdate get installed at:
NTP Cheat Sheet
Is NTP Running?
ps ax | grep ntp
Stats files directory:
Check on server status:
Stop, start, restart ntpd:
sudo /etc/init.d/ntp stop | start | restart