Unix Tip: Configuring NTP

1 comment | 1I like it!
October 28, 2004, 03:39 PM —  ITworld.com — 

Send in your Unix questions today!


See additional Unix tips and tricks


Setting up a Unix system to be an NTP client is generally straightforward.
On those Unix platforms that include NTP in the default configuration,
you may only need to make a few adjustments to NTP's default configuration
file for the system to sync up to a reference time server(s) and keep
good time. On a Solaris system, for example, this involves copying a
prototype file and customizing it. You can insert the names or IP addresses
of the time server(s) you have elected to use -- whether public NTP servers
or NTP servers that you have set up on your local network -- or configure
the system to receive broadcast time updates. Once a system has been
configured, the NTP daemon will start whenever the system boots and run
continuously in the background.



Configuration of NTP servers, on the other hand, can be simple or complex,
depending on the options that you wish to use and how well you understand
the NTP service.



Many Unix systems today ship with NTP software. These include Solaris, SCO,
FreeBSD and Mac OS X. On some Linux systems, you will need to download and
install a package, such as ntp-4.1.2-5.i386.rpm, to acquire NTP services.



Once configured, the NTP service requires little or no administration. New
clients will have to be configured and an occasional verification of your
time sources may be warranted, but the service otherwise runs unattended.



Boot-time NTP




If you only want to synchronize your systems at boot time, you can configure
an ntpdate command in your start scripts. This will ensure that your system
starts up with a reasonable clock setting. On a Solaris system, this might
be done with a script like that shown below, installed as /etc/rc2.d/S73ntpdate.




------------------------------ cut here ------------------------------



#!/bin/sh

#

# synchronize date to NTP server at start-up

/usr/sbin/ntpdate -s -b -p 8 -u 129.6.15.28 216.200.93.8


------------------------------ cut here ------------------------------




In this start script, we're synchronizing our system clock to publicly
available time servers in the Washington, DC area. The options used in this
command are as follows:



option means

-s divert logging output to syslogd

-b force time stepping instead of skewing

-p specify number of time samples to be obtained from the server

-u use an unprivileged port (this can be important if privileged ports are

blocked by a firewall). NOTE: NTP uses port 123.




Notice that the ntpdate command in the script includes all the information that
it needs to run, obviating the need to insert this information from the NTP
configuration file.




On systems which boot from rc.conf files (such as FreeBSD and its derivatives),
you would need to modify additional files to use NTP. For example, you would
enable ntpdate in the /etc/rc.conf file by setting ntpdate_enable="YES".
Arguments for the ntpdate command, including the server(s) you intend to
obtain time information from need to be included in the ntpdate_flags line.
These lines might look like this:




ntpdate_enable="YES"

ntpdate_flags="-b 129.6.15.28 216.200.93.8"




Using the ntpdate command on system boot will keep your system clocks in
closer proximity and is generally a good idea. At the same time, for
synchronization, using only boot time commands is of very limited utility.
Many Unix systems run for months, even

I like it!
Comments

cheap wow gold

You know ,I have some wow gold,and my friend also has some World of Warcraft Gold,do you kouw they have the same meaning,Both of them can be called
warcraft gold,I just want to
buy wow gold,because there are many
cheap wow gold
| reply

multcast versus broadcast NTP client

Greetings,

What is needed in the ntp.conf file to tell a client
to listen for a broadcast? (not multicast...)

Thanks!
Jay
| reply
Free books

Essential JavaFX
Get started building rich Web apps quickly with an introduction to the power of JavaFX key features -- scene node graphs, nodes as components, the coordinate system, layout options, colors and gradients, custom classes with inheritance, animation, binding, and event handlers.Enter now!

The Nomadic Developer
Consulting can be hugely rewarding, but it's easy to fail if you are unprepared. To succeed, you need a mentor who knows the lay of the land. Aaron Erickson is your mentor, and this is your guidebook. Enter now!

Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

Marketplace