Distroname and release: Debian Squeeze

Sync the date and time with an internet server (NTP)

If you want to make sure that the clock match the world clock it is possible to to do using ntp. It is very usefull, to make sure that all servers are always in sync with the correct time!

It is very easy, actually it is just of matter of installing the package. For me it was not needed to configure or do anything to get the correct time.

Please note that this could be kinda "dangerous" since the data in logfiles could be affected as well! So it is highly recommended to do on a system that is not completely configured, or at least the logfiles must be backed up, if they should be needed for later usage!


#aptitude install ntp
I would recommend to use servers as close to your location as possible to get more perfect time-match with less delay.
A list of pools, which it is called can be found here:

Next edit the /etc/ntp.conf to match the servers, and replace the existing servers with the one closest to you.
server 0.dk.pool.ntp.org iburst
server 1.dk.pool.ntp.org iburst
server 2.dk.pool.ntp.org iburst
server 3.dk.pool.ntp.org iburst
Save the file, and restart ntp.
/etc/init.d/ntp restart
Now the clock will sync.

If you now check the syslog it should show something like this.
#cat /var/log/syslog |grep ntp
Apr 11 09:59:06 loke ntpd[2501]: synchronized to, stratum 2
Apr 11 11:04:34 loke ntpd[2501]: synchronized to, stratum 2

Check the clock

You can also check that the time is correct by matching the local date time with the ntptime.

First the date.
Sun Apr 11 16:56:09 CEST 2010
Right next run ntptime. It should match, or be very close since we did not run the commands at the exactly same time!
ntp_gettime() returns code 0 (OK)
  time cf6c618b.48731000  Sun, Apr 11 2010 16:56:11.283, (.283006),
  maximum error 380145 us, estimated error 14624 us
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset 11449.000 us, frequency -34.623 ppm, interval 4 s,
  maximum error 380145 us, estimated error 14624 us,
  status 0x1 (PLL),
  time constant 6, precision 1.000 us, tolerance 512 ppm,
  pps frequency 0.000 ppm, stability 512.000 ppm, jitter 200.000 us,
  intervals 0, jitter exceeded 0, stability exceeded 0, errors 0.
Thats it :)
Do not trust the authors words! POC, tests and experience is key

Copyright LinuxLasse.net 2009 - 2024 All Rights Reserved.

Valid HTML 4.01 Strict Valid CSS!