HOWTOlabs  
 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

  ntp-4.2.0.a.20050816-0.FC4

# 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 pool.ntp.org project.
  server 0.fedora.pool.ntp.org
  server 1.fedora.pool.ntp.org
  server 2.fedora.pool.ntp.org
  server  127.127.1.0     # 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
  ==============================================================================
  *astro1.as.ap.kr 149.156.70.5     2 u   26  128  377  211.011  -16.233   3.339
  +ns01.deu.edu.tr 195.113.144.201  2 u   96  128  377  255.009   -1.504  10.386
  +detritus.mpipsy 192.53.103.108   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
 
Elsewhere
  • 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 

  0.centos.pool.ntp.org
  1.centos.pool.ntp.org
  2.centos.pool.ntp.org 
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 clock.redhat.com  [ 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 /setsntp:time.us.scalix.com

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

> net time /querysntp
  The current SNTP value is: time.us.scalix.com

> 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 ntp.new /etc/ntp.conf
2,3c2,6
< restrict default ignore
< restrict 66.187.224.4 mask 255.255.255.255 nomodify notrap noquery
---
> # restrict default ignore
> # restrict 66.187.224.4 mask 255.255.255.255 nomodify notrap noquery
> restrict 69.25.96.13 mask 255.255.255.255 nomodify notrap noquery
> restrict 207.200.81.113 mask 255.255.255.255 nomodify notrap noquery
> restrict 207.126.98.204 mask 255.255.255.255  nomodify notrap noquery
16c19
< # restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap
---
> restrict 10.17.0.0 mask 255.255.0.0 nomodify notrap
24,28d26
< # restrict mytrustedtimeserverip mask 255.255.255.255 nomodify notrap noquery
< # server mytrustedtimeserverip
<
<
<
30c28
< #multicastclient                      # listen on default 224.0.1.1
---
> # multicastclient                     # listen on default 224.0.1.1
49,50c47,51
< server 66.187.224.4
< fudge 127.127.1.0 stratum 10
---
> # server 127.127.1.0 # local clock
> # fudge       127.127.1.0 stratum 10
> server 69.25.96.13          # nist1.symmetricom.com
> server 207.200.81.113       # nist1.aol-ca.truetime.com
> server 207.126.98.204       # nist1-sj.glassey.com
66c67
< authenticate yes
---
> authenticate no
78a80,82
>
> # Alternate logfile
> logfile /var/log/ntp


[fredness@bilbo ntp]$ pwd
/etc/ntp

[fredness@bilbo ntp]$ cat ntpservers
nist1.symmetricom.com
nist1.aol-ca.truetime.com
nist1-sj.glassey.com
clock.redhat.com
clock2.redhat.com

[fredness@bilbo ntp]$ cat step-tickers
nist1.symmetricom.com
nist1.aol-ca.truetime.com
nist1-sj.glassey.com
clock.redhat.com
clock2.redhat.com

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

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


Neo - use net time to get time from another host
================================================

$ diff ntp.new /etc/ntp.conf
  ...

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

  ...
zap technologies
tablet | printable