Keeping Your Desktop Time
Desktop Training - Ubuntu

NTP is a Network Time Protocol that connects your local machine to a remote server to configure your local time correctly. Often users do not realize that their machine is actually making these remote connections.

In order to synchronize to Internet time servers you will need to install NTP support.  Choose  System/Administrator/Time and Date and then select “Keep synchronized with Internet servers” Instead of Manual. 
Ubuntu training course tutorial Network Time Protocol

 

If NTP support is not available you will be asked to install it by supplying your administrator password.
Ubuntu training course tutorial Network Time Protocol

Once it is installed close Time and Date and then reopen if for the changes to take effect.
Ubuntu training course tutorial Network Time Protocol


Select one or more time servers so that your system will synchronize with the time server on a regular basis.
Ubuntu training course tutorial Network Time Protocol


Network Time Protocol is a daemon so it will listen for connections to be made to the NTP time server.
Open a terminal and type:

netstat -aunt
udp        0      0 192.168.5.43:123        0.0.0.0:*                          
udp        0      0 127.0.0.1:123           0.0.0.0:*                          
udp        0      0 0.0.0.0:123             0.0.0.0:*   

This shows that your Desktop is listening on port 123 for a time update from the remote Internet Servers.

The other indication that you will see is when you look at your logs in /var/log/syslog.  

Jun 17 08:21:21 ub ntpd[9576]: ntpd This e-mail address is being protected from spambots. You need JavaScript enabled to view it -o Fri Mar  7 20:24:07 UTC 2008 (1)
Jun 17 08:21:21 ub ntpd[9577]: precision = 1.000 usec
Jun 17 08:21:21 ub ntpd[9577]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled
Jun 17 08:21:21 ub ntpd[9577]: Listening on interface #1 wildcard, ::#123 Disabled
Jun 17 08:21:21 ub ntpd[9577]: Listening on interface #2 lo, ::1#123 Enabled
Jun 17 08:21:21 ub ntpd[9577]: Listening on interface #3 eth0, fe80::21b:fcff:fe68:6833#123 Enabled
Jun 17 08:21:21 ub ntpd[9577]: Listening on interface #4 lo, 127.0.0.1#123 Enabled
Jun 17 08:21:21 ub ntpd[9577]: Listening on interface #5 eth0, 192.168.5.43#123 Enabled
Jun 17 08:21:21 ub ntpd[9577]: kernel time sync status 0040
Jun 17 08:25:41 ub ntpd[9577]: synchronized to 91.189.94.4, stratum 2
Jun 17 08:25:41 ub ntpd[9577]: time reset -0.209526 s
Jun 17 08:30:51 ub ntpd[9577]: synchronized to 91.189.94.4, stratum 2

From these logs you can see that the Desktop is synchronized to two separate time servers each which are stratum 2.  Stratum 1 is a time server connected to an atomic clock or a radio frequency clock.  So a stratum 2 gets it's time from a server that is a stratum 1 server.  Each time the connection is made to the server a time offset will occur.

Enable Stats
You can view stats, which are not too useful, by enabling stats in the /etc/ntp.conf file and uncommenting the lines so it looks like this:

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

Once you do this restart your ntp server.

# /etc/init.d/ntp restart
* Stopping NTP server ntpd                                              [ OK ]
Starting NTP server ntpd                                              [ OK ]

Here is a look at those stats.

54634 54912.805 91.189.94.4 9014 -0.003789257 0.215213312 7.937502568 0.000000954
54634 54913.693 131.216.22.15 9014 -0.010979699 0.102440485 7.937516505 0.000000954

Here is a helpful command to be done as root to see what server is keeping your time.

# ntpq -p
remote               refid          st     t when poll reach   delay   offset  jitter
================================================================
+europium.canoni 192.36.133.17        2     u   35   64  377  213.401    2.271   2.136
*egr-dns-1.egr.u 69.25.96.13          2     u   27   64  377   98.623   -6.359   1.565

The line with the * is the server that is currently used to set the clock on your Desktop.