Up one level
Synchronizing your clock with atomic time in Linux (NTP)
Spencer Stirling

Have a look at this website which outlines the use of NTP in Linux.

I ran into a few bumps (as usual) trying to get this system to work. NTP in Linux can run using three different methods:

  1. A daemon (named ntpd) which constantly updates the time using servers on the internet
  2. A cron process (a regularly-scheduled update)
  3. Manually invoking "ntpdate server1 [server2 ...]" - note that this can be put into your startup scripts so that the time is updated each time the computer restarts

Personally, I prefer the first method. If you are running Debian, then installation is easy. Just apt-get the package "ntp-simple". Then you will need to edit the file "/etc/ntp.conf". In it you will find the line

server pool.ntp.org

You should just make several (I made 2) copies of this line, one after another, like so

server pool.ntp.org
server pool.ntp.org

This just chooses a couple of servers (from a pool of servers) in case one of them doesn't actually work.

NTP used in this "daemon mode" works right out of the box. Note that it will take at least a half hour to actually update the time, so don't worry if it doesn't work right away.

Caveat: This method didn't work on my laptop (which is running a derivative of Debian called Xandros - see below for the resolution).

The second method (regularly-scheduled cron process) probably works fine, but I see little reason for using it.

I actually had to resort to using the third "ntpdate" method on my laptop. This works fine since the laptop is restarted quite often anyway, so the clock will never drift too far from the actual time.

The utility ntpdate can be run at the command line like so

ntpdate server

In order to automate this, I placed the lines

ntpdate -sb server1 [server2 ...]
hwclock --systohc

in one of my startup scripts. I think that I placed the lines at the bottom of "/etc/init.d/bootmisc.sh" which is a startup script meant for miscellaneous tasks. It worked perfectly. Of course, in order to run this, I needed to specifically find some atomic time servers - these are listed on the NTP Servers website.

This page has been visited   times since April 8, 2005