FreeBSD Server Administration

« Hide Apache and PHP Information in HTTP Headers | Main | Httpd Exited on Signal 11 - Caused by Buggy Script »

July 30, 2005

Keep Accurate Time with ntpd and ntpdate

Obviously, keeping the server time accurate is very important. I should have done this before the server was public.

Adjust server time manually
# ntpdate pool.ntp.org

Alternatively, you can make the process automate
1. Create a file /etc/ntp.conf with the following content:
server pool.ntp.org
driftfile /etc/ntp.drift

2. Start ntpd:
# ntpd

3. To enable ntpd to start at boot time, add one line in /etc/rc.conf: (optional)
ntp_enable="YES"

The ntp server "pool.ntp.org" is recommended by ntp.org, you can also select another one, check out ntp.org for details.


Category : Command & Utility

Posted by FreeBSD Newbie at July 30, 2005 05:47 PM

Comments

Starting ntpd at boot is an extremely poor idea. A much better program is to cold boot a server with ntpdate at boot, followed by a minimum of 72 hours running a "top of the hour" cron job to execute ntpdate 72 times.

After your system has attained its best stabilized temperature and kernel pll levels normalize along with an estimated error of 0.003 or less, then it's time to launch ntpd.

Unless your server is running a GPS reference clock (stratum 1, in other words) and/or has a temperature compensated compartment whose purpose is to stabilize clock chip rates (with the side effect of stabilizing the system time), for the good of the ntp network community sysops should wait until the machine has been running 72 hours and has settled into a predictable pattern of heat generation and dissipation which can be compensated.

If your machine has clock chips so unstable that you are unable to attain 0.003 estimated error, kernel pll lock does not happen, or the frequency of clock and other critical members of the chipset conspire to create an aggregate error that either exceeds the levels established by ntpd configs or results in a clock that moves in unpredictable and uncorrectable ways, your "server" will not even be allowed to connect as a client at most locations where ntpd is run.

Ntpd samples 16 peers in the general network neighborhood. It finds them without operator input. There will be 3 at "stratum 4" which will not be polled. If their clocks have not stabilized within 72 hours some configurations will exclude them. There are peers at stratum 1 (normally 3) along with peers at stratum 2. As your server first joins a group, and particularly if your clock was not stabilized before you connected, you will find that only stratum 2 servers will peer with stratum 3, which is where most machines end up that have not been running at least 15 days.

Bottom line? Fast, fancy new system boards generate lots of heat which degrades the accuracy of your system clock. Let it "burn in" for a good long time before launching an ntpd server.

Posted by Clark at May 9, 2006 12:19 PM

Thanks for your very helpful comment, Clark. You are absolutely right, running ntpdate in a cronjob is a much better solution. Actually I did that too, somehow I wrote a different method in the post.

Posted by FreeBSD Newbie at April 2, 2008 05:18 PM

Post a comment



(Optional, will not be shown to the public)

Remember Me?