Next Previous Contents

26. NTP Time calibration

Some of you might be wondering why didn't originally use to support XNTP. Why? Getdate is 37k with ALL the sources and compiled binaries where as Ntp-4.0.72i is over 8.8MB! For fricken just time calibration! Yes, Xntp does a LOT more than getdate but for the purposes we need here, it is MASSIVE overkill. But, many distributions come with it built-in so I will support it now.

I've been also told that newer versions of Slackware comes with "netdate" which is supposed to be just as good as "getdate". Since this only exists on Slackware, I'll stick with getdate and xntp for now.

IMPORTANT:

Redhat Users:

- Download "xntpd" or "getdate" (URLs in Section 5 and put it in /usr/src/archive

Compiling Getdate:

Compiling Xntp:

26.1 - The Getdate way:

- Edit the /usr/local/sbin/getdate file and make it look like so:

For example, this is what I use. Edit it to use servers local to you

/usr/local/sbin/get-date


#!/bin/sh
#
# Version: 07/03/00
#
# Part of the copyrighted and trademarked TrinityOS document.
# <url url="http://www.ecst.csuchico.edu/~dranch">
#
# Written and Maintained by David A. Ranch
# dranch at trinnet dot net
#
# Updates:
#
# 07/03/00 - Added comments for users who want to save the date in UTC
#
# The "clock" command sets the CMOS clock time as well.
#
timehosts="otc2.psu.edu wwvb.erg.sri.com ntp.nasa.gov"
#

if /usr/local/bin/getdate -adjust 10 200 $timehosts > /dev/null; then
        /sbin/clock --systohc

    # NOTE: If you want to set your local to UTC, append "--utc" to the
    #       above "hwclock" line
fi

26.2 - The xntp way:

- Edit the /usr/local/sbin/set-clock file and make it look like so:

For example, this is what I use. Edit to use servers local to you

/usr/local/sbin/set-clock


--
#!/bin/sh
#
# Version: 07/03/00
#
# Part of the copyrighted and trademarked TrinityOS document.
# <url url="http://www.ecst.csuchico.edu/~dranch">
#
# Written and Maintained by David A. Ranch
# dranch at trinnet dot net
#
# Updates:
#
# 07/03/00 - Added comments for users who want to save the date in UTC
#
# The "clock" command sets the CMOS clock time as well.
#
timehosts="otc2.psu.edu wwvb.erg.sri.com ntp.nasa.gov"
#
if /usr/sbin/ntpdate -ub $timehosts > /dev/null; then
    /sbin/hwclock  --systohc

    # NOTE: If you want to set your local to UTC, append "--utc" to the
    #       above "hwclock" line
fi
--

There are TWO examples shown here:

I recommend the once-an-hour method. The 15 minute method is primarily for users running Diald since the NTP traffic will bring up the link every 15 minutes.

- Slackware users:

- Edit "/var/spool/cron/crontab/root" and add this line to the bottom of the file:

- 60 minutes with "xntp"


                        * 0-23 * * *      /usr/local/sbin/set-clock

- 60 minutes with "getdate"


                        * 0-23 * * *      /usr/local/sbin/get-date

- 15 minutes with "xntp"


                        0,15,30,45 * * * *      /usr/local/sbin/set-clock

- 60 minutes with "getdate"


                        0,15,30,45 * * * *      /usr/local/sbin/get-date

- Lastly, tell CRON to re-read it's configuration file by running:

- Redhat users

- 15 minutes

- Edit the /etc/crontab file and ADD this line ABOVE the cron.hourly line.


                                0,15,30,45 * * * * root run-parts /etc/cron.15min

- Link the script


                                ln -s /usr/local/sbin/get-date /etc/cron.hourly/get-date

- Tell CRON to re-read it's configuration file by running:

- 60 minutes

- This hourly cron directory is already setup in Redhat

- Link the script

- 60 minutes the "xntp" way


                                        ln -s /usr/local/sbin/get-date /etc/cron.hourly/set-clock

- 60 minutes the "getdate" way


                                        ln -s /usr/local/sbin/get-date /etc/cron.hourly/get-date

- 15 minutes the "xntp" way


                                        ln -s /usr/local/sbin/get-date /etc/cron.15min/set-clock

- 15 minutes the "getdate" way


                                        ln -s /usr/local/sbin/get-date /etc/cron.15min/get-date


Next Previous Contents