Benutzer-Werkzeuge

Webseiten-Werkzeuge


 [[anwenderwiki:linbo:ntp_sync]] 

Zeit in LINBO per ntp setzen

Es gibt schon länger den Wunsch, dass LINBO die Systemzeit synchronisiert und setzt.

Ab Version 2.3.12 kann LINBO die Systemzeit setzen und hat einen ntp-client an Bord:

Version 1: ntpd (ca. 6Sekunden)

Mit Hilfe von ntpd (dauert ca. 6 Sekunden), Genauigkeit so klein, wie ntp das eben kann (besser als bei Version 2). Im Postsync-skript:

echo -n "Setting date from: [$(date)] to ...wait for it... "
ntpd -nq -p 10.16.1.254
hwclock -u -w
echo -n "[$(date)]"

Version 2: daytime (0Sekunden)

mit Hilfe von daytime auf dem ipfire dauert es 0 Sekunden. Die Genauigkeit liegt aber bei ⇐1s. IM postsync-skript:

echo -n "Setting date from: [$(date)] to "
date -D '%s' -u -s `nc 10.16.1.254 13`
hwclock -u -w   

dafür muss man auf ipfire den dienst xinetd installiert haben und folgendes konfiguieren:

server~# ssh ipfire 
[root@ipfire ~]# pakfire install xinetd
...
PAKFIRE INFO: Is this okay? [y/N]
y
...
[root@ipfire ~]# cat << EOF > /etc/xinetd.d/daytime
#default: off
# description: An internal xinetd service which gets the current system time
# then print as seconds from epoch, use external date command
# This is the tcp version.
service daytime
{
        disable         = no
        type            = UNLISTED
        id              = daytime-stream
        socket_type     = stream
        protocol        = tcp
        user            = root
        wait            = no
        port            = 13
        server          = /root/epoch-daytime
}
EOF
[root@ipfire ~]# echo -e '#!/bin/sh\ndate "+%s"' > /root/epoch-daytime
[root@ipfire ~]# chmod 755 /root/epoch-daytime
[root@ipfire ~]# /etc/init.d/xinetd start
Starting xinetd...

der Umweg über /root/epoch-daytime ist nötig, weil „daytime“ nativ keine UTC-Zeit ausgibt und somit schlecht parsbar ist.

UTC

Natürlich gibt es ein Problem: Windows, welches UTC als Hardware-Zeit nicht so gerne versteht, siehe http://superuser.com/questions/185773/does-windows-7-support-utc-as-bios-time#185780 . Man kann Windows auch UTC beibringen (aber laut WEbsuche immer noch unter Umständen buggy in Windows 7/8/10):

   [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
   "RealTimeIsUniversal"=dword:00000001

Vielleicht gibt es auch eine einfache Möglichkeit die Hardwarezeit in LINBO auf nicht-UTC zu stellen. Ich habe keine gefunden.

Quellen

 [[anwenderwiki:linbo:ntp_sync]] anwenderwiki/linbo/ntp_sync.txt · Zuletzt geändert: 2016/11/24 09:10 von 127.0.0.1