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.
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 (220.127.116.11)
* navobs1.usnogps.navy.mil (18.104.22.168) CNAME:
* ntp.nasa.gov (22.214.171.124)
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.
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
28 Jan 20:28:45 ntpdate: step time server 126.96.36.199 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.
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.