Keeping Accurate Time on Linux - Page 2

 By Carla Schroder
Page 2 of 3   |  Back to Page 1
Print Article

Finding Public Time Servers

First up, where to find time servers? Visit Public NTP Time Servers. Select servers that are closest to you. Geographically close is good, or you can test network proximity with ping and traceroute.

Select three to five servers; don't rely on any single one. Be sure to pay attention to the access policies for each server, because some are open and some have restrictions (musn't be guilty of time server abuse).

ntp.conf entries look like this:

server    clock.fmt.he.net
server    dewey.lib.ci.phoenix.az.us
server    clock.sjc.he.net

While your time zone is probably set correctly already, it's easy enough to check:

$ ls -al /etc/localtime
lrwxrwxrwx 1 root root 30 Nov 25 13:45 /etc/localtime -> /usr/share/zoneinfo/US/Pacific

If you need to change it, use the ln command:

# ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime

If your system time is off by more than a few minutes, ntpd will not correct it. ntpdate will give it a good jumpstart:

# ntpdate [server name]

Starting ntpd depends on your Linux distribution. If you installed it from RPM or apt-get, it's probably already running and the init scripts are in place. On Red Hat, try 'restart' or 'start' first:

# service ntpd restart

On other Linuxes:

# /etc/init.d/ntpd restart

Debian Is Different, Of Course

Note that Debian uses the ntp-simple package, and you have to install ntp-docs separately. After installation, you'll find them on your system at /usr/share/doc/ntp-doc/html/.

Debian also uses /etc/default/ntp-servers to set the time servers for /etc/init.d/ntpdate. The easiest time server configuration method on Debian is:

# dpkg-reconfigure ntp-simple

You may also edit the configuration files directly. dpkg-reconfigure will add your server list to both /etc/default/ntp-servers and /etc/ntp.conf.

To restart the ntp daemon on Debian, use this command:

# /etc/init.d/ntp-simple restart

Page 3: LAN Clients

This article was originally published on Jan 22, 2004
Get the Latest Scoop with Networking Update Newsletter