Without backing up through the technical details described by others, here's the case for using NTP to keep your system clocks synchronized with universal coordinated time (known as UTC, the French abbreviation). The stratum one time servers around the world are referenced to the atomic clocks scattered around the world (and coordinated with one another, thus the name). You PC platform has a notoriously inaccurate clock (really!) along with a second clock embedded in the Linux kernel and it's a Real Good Idea to keep those coordinated with each other and to an external time reference to avoid problems that can crop up otherwise. Running the NTP daemon is the best solution anybody's ever come up with for accomplishing that.
You're in Argentina. NTP Pool (http://www.pool.ntp.org/zone/ar
) recommends three pool servers:
You would place those in your /etc/ntp.conf
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
Are the local clock
entries necessary? Yes, they are. If you lose your internet connection NTP will fall back on the local clock and continue running until the internet comes back when it will then synchronize with one of the pool servers listed.
Other entries in /etc/ntp.conf
might include these:
# Drift file.
# Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
Should already be in /etc/ntp.conf
and uncommented; the file, /etc/drift
, should have a numeric value in it after NTP has been running for a while. That number represents the drift of your local clock versus UTC and is used by the NTP daemon to fine-tune your clock to UTC (it's not seconds, it's a scaling value). I have found it useful in a newly installed NTP to insert 0.0 in /etc/ntp/drift
-- I don't remember exactly why but it's what I've done for years and it seems to work rather than leaving the file empty to begin with (NTP eventually will write a value in the file either way).
# Log file
logconfig=allclock +allpeer +allsys +allsync
It can be useful to look at the log file periodically. A normally working NTP will look something like this:
22 Jul 04:40:03 ntpd: Listen normally on 6 multicast 18.104.22.168 UDP 123
22 Jul 04:40:03 ntpd: Joined 22.214.171.124 socket to multicast group 126.96.36.199
22 Jul 04:40:03 ntpd: LOCAL(0) 8011 81 mobilize assoc 35766
22 Jul 04:40:05 ntpd: 188.8.131.52 8011 81 mobilize assoc 35767
22 Jul 04:40:08 ntpd: 184.108.40.206 8011 81 mobilize assoc 35768
22 Jul 04:40:09 ntpd: 220.127.116.11 8011 81 mobilize assoc 35769
22 Jul 04:40:09 ntpd: 0.0.0.0 c016 06 restart
22 Jul 04:40:09 ntpd: 0.0.0.0 c012 02 freq_set kernel 77.276 PPM
22 Jul 04:40:10 ntpd: LOCAL(0) 8024 84 reachable
22 Jul 04:40:10 ntpd: LOCAL(0) 963a 8a sys_peer
22 Jul 04:40:10 ntpd: 0.0.0.0 c515 05 clock_sync
22 Jul 04:40:12 ntpd: 18.104.22.168 8024 84 reachable
22 Jul 04:40:13 ntpd: 22.214.171.124 8024 84 reachable
22 Jul 04:40:15 ntpd: 126.96.36.199 8024 84 reachable
22 Jul 04:44:32 ntpd: 188.8.131.52 963a 8a sys_peer
Those few lines simply show what a working NTP looks like; if there were problems, those would show up in the same log.
If you're going to use the logging, you may want to add this to /etc/logrotate.d/ntpd
The logs can get large -- I keep 10 compressed logs, a more practical number might be 3. Simply change rotate 10
to rotate 3
in the above.
All you have to do to use the NTP daemon is edit your /etc/ntp.conf
file, pretty much leaving it alone except for the server entries (and, maybe, the log file entries) then make /etc/rc.d/rc.ntpd
executable (chmod 755 /etc/rc.d/rc.ntpd
Make sure you've set your system in the correct time zone. Buenos Aires is 3 hours offset from UTC and apparently does not use daylight saving time; if it's 1700 UTC, it's 1400 ART.
Do a one-time set the clock as you have been then start the NTP daemon:
(you must do all the above as root).
Wait about five minutes then, again as root (or su -
remote refid st t when poll reach delay offset jitter
LOCAL(0) .LOCL. 10 l 45h 64 0 0.000 0.000 0.000
+205-196-146-72. 184.108.40.206 2 u 355 1024 377 1615.36 -8.986 52.792
*four10.gac.edu 220.127.116.11 2 u 967 1024 377 1384.06 -56.502 39.132
+framboise.hoopy 18.104.22.168 2 u 925 1024 377 1366.12 -41.546 50.117
You should see something similar to this (you can execute ntpq -p
anytime). This indicate that the daemon has synchronized to the host identified with the asterisk (*). Yours will never be the same hosts as shown (these are US pool servers). Note that you can also use ntpq -pn
to show the IP addresses of the pool servers rather than the fully qualified name (no DNS look up involved, it's quicker).
Once synchronized, NTP will keep your clocks synchronized to UTC and you don't need to worry about running a cron job every so often to set the clocks, it'll just happen.
Now, all the above assumes that your system(s) run 24/7 and your internet connection is also 24/7; NTP will work if the system has been turned off and your clocks haven't drifted too far during the powered-off period and that the internet connection is available before you boot. If you need to boot your system and manually start your internet connection, just change /etc/rc.d/rc.ntpd
to mode 644 (so it won't automatically start), make your connection then start the daemon
su - (or sudo)
sh /etc/rc.d/rc.ntpd start
Hope this helps some.