System: NTP: setting up

(last edit: 2001-04-12)

Introduction

NTP stands for Network Time Protocol and is used to set the time on your system. There are two programs which you must use:
  • ntpdate
  • ntpd

ntpdate

Ntpdate sets the time and exits and thus it won't keeps setting the time, for this you have to start ntpd. Ntpdate should be started with the following options: man ntpdate -b Force the time to be stepped using the settimeofday(2) system call, rather than slewed (default) using the adjtime(2) system call. This option should be used when called from a startup file at boot time. -s Divert logging output from the standard output (default) to the system syslog(3) facility. This is designed primarily for conve- nience of cron(8) scripts. Don't use the '-s' option when starting from the commandline. Example: --- root@hosts:~#date Mon Jan 1 01:52:39 GMT 2001 root@hosts:~#>ntpdate -b ntp.demon.nl ntp.demon.co.uk 12 Apr 13:48:51 ntpdate[871]: step time server 194.159.73.44 offset 8769368.344914 sec root@hosts:~#>date Thu Apr 12 13:48:53 GMT 2001 --- As you might notice this is GMT (or now called UTC) time and you probaley live in a different timezone. Changing your timezone You can change your timezone with 'sysinstall', with 'tzsetup' and like a good unix is supposed to be by hand. I haven't veriefied but I pretty sure 'sysinstall' starts the 'tzsetup' program when you select 'configure | timezone'. When you start 'tzsetup' it will ask you a few simple questions and it will set your timezone. What it actually does is copy a timezone from '/usr/share/zoneinfo' to the file '/etc/localtime' and updates the system date. I you want to do it your self then you copy the required timezone over the '/etc/localtime' file and you execute 'adjkerntz -a': --- root@host:/#date Thu Apr 12 14:12:21 CEST 2001 root@host:/#cp /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime root@host:/#adjkerntz -a root@host:/#date Thu Apr 12 16:12:21 CEST 2001 ---

ntpd

Ntpd sets the system date AND maintains it. It uses a config file named '/etc/ntp.conf'. This file should look something like this: --- server ntp.demon.nl server ntp.demon.co.uk driftfile /var/db/ntp.drift --- From the ntp documentation ('/usr/share/doc/ntp'): Note the inclusion of a driftfile declaration. One of the things the NTP daemon does when it is first started is to compute the error in the intrinsic frequency of the clock on the computer it is running on. It usually takes about a day or so after the daemon is started to compute a good estimate of this (and it needs a good estimate to synchronize closely to its server). Once the initial value is computed, it will change only by relatively small amounts during the course of continued operation. The driftfile declaration indicates to the daemon the name of a file where it may store the current value of the frequency error so that, if the daemon is stopped and restarted, it can reinitialize itself to the previous estimate and avoid the day's worth of time it will take to recompute the frequency estimate. Since this is a desirable feature, a driftfile declaration should always be included in the configuration file.

rc.conf

If you want all these nice things to happen when you boot your machine then add these to the '/etc/rc.conf' file: ntpdate_enable="YES" ntpdate_program="ntpdate" ntpdate_flags="-bs ntp.demon.nl ntp.demon.co.uk" xntpd_enable="YES" xntpd_program="ntpd" NOTE: although I've been using ntp.demon.nl through this document you should realy find a good ntp server near you (probaley ntp.provider.blabla)

Click here to go back to the index.