Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

System Clock Drift

Some system clocks do not run all that accurately. Some hints on dealing with clock problems can be found in the Clock mini HOWTO at http://www.tldp.org/HOWTO/Clock.html, but the hwclock and adjtimex manual pages tend to be an easier read!

Be warned though, the Debian suggestion is not to fiddle with hwclock. It is highly recommended that you install the ntp-simple package (to run a daemon that checks regularly to keep your clock in sync) and/or ntpdate (to update your clock at each boot or to manually run a command to update your clock) to keep your clock accurate. These are discussed in more detail below.

If you install both ntp-simple and ntpdate and you manually set up cron to run ntpdate every hour then you will probably receive email every hour to tell you that ntpdate can't get the ntp socket (because the ntpd daemon from ntp-simple is probably using it!):

  6 Oct 09:08:02 ntpdate[23856]: the NTP socket is in use, exiting

Just install one of them!


Using NTP

The Network Time Protocol (NTP) daemon provided by the ntp-simple package is by far the easiest way to manage the accuracy of your clock, particularly if you are connected to the internet (even if only intermittently).

The ntp-simple daemon (ntpd) effectively sets the clock by speeding it up or slowing it down depending on its natural drift so that it gets in sync and stays there. This avoids a “sudden shock” to the system with a dramatic change to the time, although mostly the system can handle it.

The primary configuration required is to identify an NTP server. Look at the lists at http://www.eecis.udel.edu/~ntp/, for example.

After running ntpd for a little while your clock will be set to an accurate time and will maintain an accurate time. However, if the amount of difference is too great then ntpd will not modify the clock. After setting up ntp-simple you can install ntpdate and on install (and reboot) the clock will be updated to the correct time according to the server you have chosen for ntp-simple.

With ntp-simple installed on one of your hosts, Velox (39.47) for example, on the local network you can now use Velox (39.47) as a ntp server simply by installing ntp on each machine and pointing them to Velox (39.47) as the server.

ntpdate

If you only have irregular access to the Internet then ntpdate is useful. The package provides the ntpdate command to query an NTP server and to update your clock. You can do this manually as you see fit with:

  $ ntpdate ntp.togaware.com

The advantage is that you will not have regular net transmissions as with the NTP server. This could save you up to 4MB per day. This could also be done as a cron job, for example.

For irregular access through a modem using PPP though, a good idea is to create a script file in /etc/ppp/ip-up.d called ntpdate containing:

#!/bin/sh

#invoke ntpdate to set time from system clock
if [ -x /usr/sbin/ntpdate ]; then
        /usr/sbin/ntpdate -s -t 5 ntp.togaware.com
        /sbin/hwclock --systohc
fi

Make sure the script is executable:

  # chmod a+rx /etc/ppp/ip-up.d/ntpdate

Then each time you connect the local clock will be synchronised with the NTP server.


Subsections
Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © Togaware Pty Ltd. . Creative Commons ShareAlike V4.