Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:ntp

Network Time Protokol NTP

This is a description how to setup your computer in order to fetch the accurate time from the internet. — 2004-11-26, 2006-12-14, 2012-05-05;

Infos taken from: How do I use pool.ntp.org?, Pool Servers (Time Synchronisation with NTP & NTP FAQ and HOWTO)

In /etc/ntp.conf uncomment the line

  1. server pool.ntp.org

and add your appropriate sub-zone, eg:

server  de.pool.ntp.org

If, contrary to expectations, you have servers which do not use version 4, but the older version 3 of the NTP-protocol, add 'version 3' after the server entry, eg: server timesource.kaeser-net.de version 3. More

To manually adjust your computer clock from time to time, just issue the command ntpd -q from now on :?:

Make /etc/rc.d/rc.ntpd runnable and start it with /etc/rc.d/rc.ntpd start''

After some time (this could take as long as half an hour!), ntpq -p should output something like:

remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+81.6.42.224     193.5.216.14     2 u   68 1024  377  158.995   51.220  50.287
*217.162.232.173 130.149.17.8     2 u  191 1024  176   79.245    3.589  27.454
-129.132.57.95   131.188.3.222    3 u  766 1024  377   22.302   -2.928   0.508

The IP addresses will be different, because you've been assigned random timeservers. The essential thing is that one of the lines starts with an asterisk (*), this means your computer gets the time from the internet.

Attic

With temporary Connection (Modem)

Add this code to the file /etc/ppp/ip-up. Create it, if it not exists and make it runnable.

#!/bin/bash
# /etc/ppp/ip-up
spd=$((24*60*60)) # seconds per day ; #spd=5 # test
today=$(($(date +%s) / spd))    # today in days since 1970
last=$(($(stat -c%Y $0) / spd)) # last setting of time in days since 1970
 
if ((today>last)); then # fetch the time once a day:
    if ntpd -q; then
        touch $0 # remember time setting in the modification time stamp of this file
        logger "Time set successfully"
    else
        logger "ntpd error while setting time!"
    fi
else
    logger "No need to set time yet"
fi

:!: On my pppoe DSL connection it doesn't work!

Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/ntp.txt · Zuletzt geändert: 2012-05-05 08:43 von becki

Impressum - Datenschutzerklärung