next up previous contents
Next: 19 InstallingTomcat Up: Redhat FAQ Previous: 17 Secure Shell   Contents

Subsections

18 Time Services

By:
Stephen Carville
Rev:
12/12/01

18.1 Server Setup

  1. Install ntp from RPM or from source code
  2. Edit the file /etc/rc.d/init.d/ntpd to add the startup runlevels for chkconfig 
    # chkconfig: 345 55 10
  3. Edit the file /etc/ntp/conf to add the servers you will synchronize with. For example:
    server tick.ucla.edu 
    server ns.scruz.net 
    server ntp.ucsd.edu 
    See Section 18.3 for an example file.
  4. Start the network time daemon
    # service ntpd start
  5. Start ntpq to check if the daemon is working
    # ntpq
  6. After a few seconds check ntpd with the command ``peers''. You should see something like:
    remote           refid          st  t when  poll reach  delay offset  jitter  
    ============================================================================ 
    LOCAL(0)         LOCAL(0)       10  l   56    64   377  0.000  0.000  0.000 
    *tick.ucla.edu   .USNO.          1  u  225   512   377 26.351  65.108 9.738  
    +ns.scruz.net    bigben.cac.wash 2  u  254   512   377 22.380  64.081 8.309  
    +bigmama-ucsd-gw time.sdsc.edu  2  u  256   512   377 32.530  53.017 8.902
  7. Once the server is verified to be working correctly, add ntp to the boot sequence
    # chkconfig ntpd on 
    # chkconfig ntpd -list 
    ntpd            0:off  1:off  2:off  3:on  4:on  5:on  6:off
  8. Hardware clocks drift a lot. After a long uptime, a reboot can leave the system clock off by many hours. To prevent this, reset the hardware clock periodically:
    #!/bin/sh 
     
    # set the hardware clock every day to avoid the problem of  
    # a hard shutdown messing up the time beyond what ntp can fix  
    # easily. Drop this in /etc/cron.daily 
     
    /usr/sbin/setclock

18.1.1 Firewall

Firewalls may need to open port 37/tcp and 37/udp out.

18.2 Client Setup

The simpliest way to synchronize the time on Linux is to use rdate and one of the timeservers. Currently, congo is a timeserver. Create a script in /etc/cron.daily to query the server and set the time:

#! /bin/bash 
# example settime script 
# contact a time server and set the system time  
# requires that timezone be correctly set 
# on linux, drop in /etc/cron.daily 
 
TIMESERVER=congo 
RDATE="/usr/bin/rdate -s" 
 
$RDATE $TIMESERVER


18.3 Example /etc/ntp.conf

# ntp.conf file for a time server syncing to outside sources. 
# 
 
server          127.127.1.                # local clock 
fudge           127.127.1.0       stratum 10 
 
server          tick.ucla.edu 
server          ns.scruz.net 
server          ntp.ucsd.edu 
 
driftfile       /etc/ntp/drift 
broadcast       224.0.1.1 
broadcastdelay  0.008 
 
authenticate    no


next up previous contents
Next: 19 InstallingTomcat Up: Redhat FAQ Previous: 17 Secure Shell   Contents
2005-03-20