Configuring NTP
Config files
/etc/ntp.conf
Configuration Information
The following configuration file defines various NTP
servers to use with the primary server designated with the prefer tag. It also
creates a drift file where ntpd stores the frequency
offset. Since the documentation included with the package is sparse,
visit the NTP website at
for more information.
server time-a.nist.gov prefer
server time-b.nist.gov
server tick.usno.navy.mil
driftfile /var/cache/ntp.drift
Synchronizing the time
There are two options. Option one is to use run ntpd
continuously and allow it to synchronize the time in a gradual manner. The other
option is to run ntpd periodically (using cron)
and update the time each time ntpd is scheduled.
If you choose Option one, then create the bootscript
/etc/rc.d/init.d/ntp and put the start and
stop symlinks:
cat > /etc/rc.d/init.d/ntp << "EOF"
#!/bin/bash
# Begin $rc_base/init.d/ntp
source /etc/sysconfig/rc
source $rc_functions
case "$1" in
start)
echo "Starting ntpd..."
loadproc ntpd
;;
stop)
echo "Stopping ntpd..."
killproc ntpd
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
statusproc ntpd
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
# End $rc_base/init.d/ntp
EOF
chmod 755 /etc/rc.d/init.d/ntp
cd /etc/rc.d/init.d &&
ln -sf ../init.d/ntp ../rc0.d/K46ntp &&
ln -sf ../init.d/ntp ../rc1.d/K46ntp &&
ln -sf ../init.d/ntp ../rc2.d/K46ntp &&
ln -sf ../init.d/ntp ../rc3.d/S26ntp &&
ln -sf ../init.d/ntp ../rc4.d/S26ntp &&
ln -sf ../init.d/ntp ../rc5.d/S26ntp &&
ln -sf ../init.d/ntp ../rc6.d/K46ntp
If you prefer to start ntpd periodically, add the following command to
the root's crontab:
ntpd -q