Services     Software     Commentary     Design     Astral Musings   
Network Time
Setting up Network Time Services
Ok, here's the deal with time syncing most Linux boxen - don't bother reading all the cryptic documentation, it should just work with three provisos.
  1. If for some reason the ntp package is not installed, install it.
  2. After installation the ntpd service will need to be started.
  3. chkconfig may need to be tweaked so the ntpd service will auto start during system restart
Before starting, you might want to review the ntp.conf file server directives. Typically values are already provided and should just be used as is.
# rpm -qa | grep -i ntp


# chkconfig --list | grep -i ntp

  ntpd   0:off   1:off   2:off   3:off   4:off   5:off   6:off

# service ntpd status

  ntpd (pid 24440) is running...

# ls -ld /etc/nt*

  drwxr-xr-x  2 root root 4096 Feb 26 23:22 /etc/ntp
  -rw-r--r--  1 root root 1517 Feb 26 23:23 /etc/ntp.conf

# cat ntp.conf | grep -i server

  # --- OUR TIMESERVERS -----
  # Use public servers from the project.
  server     # local clock
Hey, how do you know ntpd is actually doing anything. Try a NTP query to see how things are going.
# ntpq -p

       remote           refid      st t when poll reach   delay   offset  jitter
  *     2 u   26  128  377  211.011  -16.233   3.339  2 u   96  128  377  255.009   -1.504  10.386
  +detritus.mpipsy   2 u   99  128  377  202.022   -3.453   4.137
   LOCAL(0)        LOCAL(0)        10 l   35   64  377    0.000    0.000   0.004
  • askubuntu: ntpd vs ntpdate: pros and cons
  • dateconfig - 'simple' graphical time sync control panel with lots of very nasty X Windows dependencies. Seriously, drop to the command line and check the ntp.conf and ntpd settings, less dependencies and you'll be able to get time syncing without having to have X Windows installed. Indeed, X Windows is typically not installed on remote servers which ironically benefit the most from having time sync enabled.

ntp step timers are configured in the step-tickers file.  If the file is empty then ntp will start using whatever time the host is currently using.  If the file has valid time servers, then as ntp is started it will carefully align time to something that closely matches the step servers before monitoring and making small time adjustments in the background.  Essentially all this does is run ntpdate using one of the supplied step servers before starting ntp service.

$ cat /etc/ntp/step-tickers 
Ok, now for how to deal with true weirdness.

If your system time is _way_ off, you'll need to bring it reasonably close to actual time before starting/restarting the ntpd service. Here are two ways to do this.
# ntpd -q    [ note, this leverages time servers listed in ntp.conf ]

# ntpdate  [ or some other stratum time server ]
If you have a really crazy system that has a wild internal clock, say a VMware session running on a box with very dynamic load, ntpd may simply just not work. Your system needs to have a reasonably stable internal clock for ntpd to work. For systems with truly wild internal clocks, better to just use sledge hammer approach of a crontab that runs a couple of times a day to set the time directly using ntpd -q or ntpdate [time server].

Note, lots of ntp documentation goes on and on about master internal servers and slave client servers. Unless you are running a server farm you will need to use the master server setup. There are directives to allow other servers to connect to you. Typically its best to leave the ntp.conf wide open and restrict access using your dedicated firewall.

This shows how to setup a Linux server as a central time server (which listens to an external highly accurate server). Also shown is how to get MS Windows and a Linux host update their time using a time service.
W2003SVR - Use Net Time to get time from another host

> net time /querysntp
  This computer is not currently configured to use a specific SNTP server.

> net time /help

> net time /

> net time
  Current time at \\CORK is 6/1/2005 11:23 AM

> net time /querysntp
  The current SNTP value is:

> net stop w32time && net start w32time
  The Windows Time service is stopping.
  The Windows Time service was stopped successfully.

  The Windows Time service is starting.
  The Windows Time service was started successfully.

Check System Event Log for confirmation

Bilbo - Act as Time Server

[fredness@bilbo fredness]$ diff /etc/ntp.conf
< restrict default ignore
< restrict mask nomodify notrap noquery
> # restrict default ignore
> # restrict mask nomodify notrap noquery
> restrict mask nomodify notrap noquery
> restrict mask nomodify notrap noquery
> restrict mask  nomodify notrap noquery
< # restrict mask notrust nomodify notrap
> restrict mask nomodify notrap
< # restrict mytrustedtimeserverip mask nomodify notrap noquery
< # server mytrustedtimeserverip
< #multicastclient                      # listen on default
> # multicastclient                     # listen on default
< server
< fudge stratum 10
> # server # local clock
> # fudge stratum 10
> server          #
> server       #
> server       #
< authenticate yes
> authenticate no
> # Alternate logfile
> logfile /var/log/ntp

[fredness@bilbo ntp]$ pwd

[fredness@bilbo ntp]$ cat ntpservers

[fredness@bilbo ntp]$ cat step-tickers

[fredness@bilbo fredness]$ diff ntpd /etc/sysconfig/ntpd
< OPTIONS="-U ntp -p /var/run/"
> OPTIONS="-A -U ntp -p /var/run/"

[root@bilbo root]# service ntpd status
ntpd (pid 2967) is running...

Neo - use net time to get time from another host

$ diff /etc/ntp.conf

# service ntpd status
  ntpd (pid 2967) is running...

zap technologies
tablet | printable