Defcon1-Header
Tool-BarfreeBSD ArticlesSearch Our SiteHOMEfreeBSD LinksContribute to FreeBSD HelpFreeBSD FilesFreeBSD Script Corner

Making your system's clock as accurate as possible

File Information: This text document may be copied, deleted, and published as desired provided credit is given to the author. If any alterations are made, each and every change must be commented as change to the original document, thank you.- Purpose: Shory and simple explanation of how to make your system's clock as accurate as possible.

Part One:  
Before we start, you should select servers which are closest to you ignored to update your system's clock. A complete list of primary servers can be retrieved from: http://www.eecis.udel.edu/~mills/ntp/clock1.htm . Considering most people are lazy I list a few of what I find to be the popular ones here:

 * bonehed.lcs.mit.edu (18.26.4.105)  
 * navobs1.usnogps.navy.mil (204.34.198.40) CNAME:
      tick.usnogps.navy.mil  
 * ntp.nasa.gov (143.232.55.5)

I do urge you to look at the complete list and find sites in your area; it helps the net run smoother, and will give you better results.

Part Two:
 Now that we have our personalized list of servers, let's take a look at HowTo update our system's clock from the command line. If you aren't already, login as root, because for practical reasons, it is the only user allowed to modify the system's clock. We will be using multiple servers in our example because it will provide better overall performance. It is very simple to just use the defaults in ntpdate, just type:

  [zartik@spot]:~$ ntpdate bonehed.lcs.mit.edu ntp.nasa.gov navobs1.usnog          ps.navy.mil
  28 Jan 20:28:30 ntpdate: bind() fails: Permission denied  [zartik@spot]:~$

 As you can see we we not successful and received an error. But alas, I was just a peon little user w/o the permissions of mighty old root. So after su'ing into root, here are my results:

  [root@spot]:/usr/home/zartik# ntpdate bonehed.lcs.mit.edu ntp.nasa.gov
                                     navobs1.usnogps.navy.mil  
28 Jan 20:28:45 ntpdate: step time server 18.26.4.105 offset 0.003293  [root@spot]:/usr/home/zartik#  

 If you desire to see how ntpdate is working, before listing the servers,add a -d option in there and it will print to the screen it's behind the scenes workings.


Part Three:
  Now that we have the command line down, it is generally common practice to both crontab this procedure as well as adding it to your /etc/rc.local startupfile. To avoid annoying test from suddenly popping up, we will be tossing in the-s option to send output to the syslog rather then console. To run ntpdate onboot, add the following line to your /etc/rc.local file:

  echo 'Updating system's clock from an atomic clock site....'  ntpdate -s bonehed.lcs.mit.edu ntp.nasa.gov navobs1.usnogps.navy.mil  

 Great, now on startup our clock will be accurate, but what about when we have those amazing 100 day uptime and we want to avoid our clock from driftingtoo far? Just add that same line from the rc.local file to ROOT's crontab file. If you do not know how to use crontab file, get a Howto on it.

 Zartik

© 1997 - 20013 Defcon1, www.defcon1.org , Copyrights for all materials on this web site are held by the individual authors, artists, photographers or creators. Materials may not be reproduced or otherwise distributed without permission of www.defcon1.org and the content's original author.

Defcon1-Header2
Tool-Bar-2Defcon1  Webmail