Bekijk Volledige Versie : Date fout?
Beste collega's,
Ik ben met mijn websites overgeschakeld vandaag naar een virtuele server op xen.
Nu kan deze virtuele server de hardware klok niet goed aflezen en staat deze dus zwaar fout:
server:/# date
wo aug 22 13:11:03 CEST 2007
Hoe kan ik manueel het uur goedzetten?
(Welk ssh commando?)
Ik zit op debian als besturingssysteem.
De tijd moet niet perfect juist zijn, zolang het maar niet meer dan een uur verschil is. Mijn sites lopen nu een beetje scheef. ;-)
HARTELIJK bedankt!
Ps: "man date" wist me geen duidelijke uitleg te geven, sorry.
installeer NTP client:
up2date ntp
Voer het volgende SSH commando uit:
/usr/sbin/ntpdate ntp1.nl.net
apt-get install ntp
=> already installed
husky01:/etc/apache2# /usr/sbin/ntpdate ntp1.nl.net
22 Aug 13:39:48 ntpdate[30829]: the NTP socket is in use, exiting
husky01:/etc/apache2# /etc/init.d/ntp status
NTP server is running.
husky01:/etc/apache2# /etc/init.d/ntp stop
Stopping NTP server: ntpd.
husky01:/etc/apache2# /usr/sbin/ntpdate ntp1.nl.net
22 Aug 13:40:08 ntpdate[30851]: step time server 193.79.237.14 offset 32049.2719
73 sec
husky01:/etc/apache2# date
wo aug 22 13:40:15 CEST 2007
Datum staat nog steeds redelijk hard verkeerd.
Dit staat er in: /etc/ntp.conf
# /etc/ntp.conf, configuration for ntpd
driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
# pool.ntp.org maps to more than 300 low-stratum NTP servers.
# Your server will pick a different set every time it starts up.
# *** Please consider joining the pool! ***
# *** <http://www.pool.ntp.org/join.html> ***
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst
# By default, exchange time with everybody, but don't allow configuration.
# See /usr/share/doc/ntp-doc/html/accopt.html for details.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
# Clients from this (example!) subnet have unlimited access,
# but only if cryptographically authenticated
#restrict 192.168.123.0 mask 255.255.255.0 notrust
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet,
In zo een geval denk ik dat het practisch is het volgende eens te proberen:
apt-get --purge remove ntp ntpdate ntp-simple (als die klaagt, een voor een)
apt-get update
apt-get install ntp ntpdate
Even met de handjes:
/usr/sbin/ntpdate -s
/sbin/hwclock --adjust
/sbin/hwclock --systohc
Mocht dit je tijd netjes bijwerken, check dan een dagje later of alles nog netjes automatisch werkt door even een incorrecte tijd te forceren.
Mocht het niet werken en niemand een nettere oplossing voorstellen, dan kan je het 2e blokje aan code in een cronjob verwerken, als tijdelijk lapmiddel. Zit je er hele uren naast, check dan je timezone config.
En dan het antwoord op je vraag:
date --set 2007-08-22
date --set 23:00:0
Doe even volgende:
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime
apt-get install command-hierboven:
Starting NTP server: ntpd.
Instellen van ntpdate (4.2.2.p4+dfsg-2) ...
husky01:/# date
wo aug 22 14:06:04 CEST 2007
husky01:/# /usr/sbin/ntpdate -s
husky01:/# /sbin/hwclock --adjust
husky01:/# /sbin/hwclock --systohc
husky01:/# date
wo aug 22 14:06:45 CEST 2007
husky01:/# ls /etc/localtime
/etc/localtime
husky01:/#
husky01:/# nano /etc/localtime
husky01:/# nano /usr/share/zoneinfo/Europe/Brussels
husky01:/# rm /etc/localtime
husky01:/# ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime
husky01:/# date
wo aug 22 14:23:38 CEST 2007
husky01:/# /usr/sbin/ntpdate -s
husky01:/# date
wo aug 22 14:23:55 CEST 2007
husky01:/# /sbin/hwclock --adjust
husky01:/# /sbin/hwclock --systohc
husky01:/# date
wo aug 22 14:24:19 CEST 2007
Ik zie het nog niet stilletjes stijgen...
Ook echt gepurged zoals ik het opgaf?
Je zou het eventueel kunnen proberen door burst iburst weg te laten in je config.
Wat voor effect heeft het volgende overigens:
ntpdate -u ntp.xs4all.nl
Ik heb hem gepurged ja.
husky01:/# date
wo aug 22 14:38:04 CEST 2007
husky01:/# ntpdate ntp.xs4all.nl
22 Aug 14:38:30 ntpdate[31815]: the NTP socket is in use, exiting
husky01:/# /etc/init.d/ntp stop
Stopping NTP server: ntpd.
husky01:/# ntpdate ntp.xs4all.nl
22 Aug 14:38:45 ntpdate[31832]: step time server 194.109.22.18 offset 32049.3004
89 sec
husky01:/# date
wo aug 22 14:38:53 CEST 2007
husky01:/#
De ntp service draait nu niet meer, nu zou die config er niet meer toe moeten doen, toch?
ik doe elke dag een rdate -s ntp.xs4all.nl en daarna sync ik de hardware clock.
ntpdate -u ntp.xs4all.nl
husky01:/# ntpdate ntp.xs4all.nl
Je hebt over de -u in zijn code gelezen.
Erzonder laat die alleen maar zien wat het verschil is.
Met de -s set je en met -u update je pas daadwerkelijk.
En die foutmelding zal die inderdaad geven als je geen -u gebruikt.
De daemon mag gewoon aanblijven als je -u gebruikt.
husky01:~# date
do aug 23 03:19:12 CEST 2007
husky01:~# date --set 12:15:0
do aug 23 12:15:00 CEST 2007
husky01:~# date
do aug 23 03:21:31 CEST 2007
husky01:~# date --set 12:15:00
do aug 23 12:15:00 CEST 2007
husky01:~# date
do aug 23 03:21:44 CEST 2007
husky01:~# date --set 2007-08-23
do aug 23 00:00:00 CEST 2007
husky01:~# date --set 12:15:0
do aug 23 12:15:00 CEST 2007
husky01:~# date
do aug 23 03:23:01 CEST 2007
husky01:~# cat /etc/timezone
Europe/Amsterdam
apt-get install rdate
=> install ok
rdate -s ntp.xs4all.nl
husky01:~# rdate -s ntp.xs4all.nl
husky01:~# date
do aug 23 03:26:07 CEST 2007
Ik krijg het niet in orde :'(
Omdat het een virtueeltje is, staat de hardware klok trouwens niet geinstalleerd, dit zou veel load veroorzaken volgens handleidingen.
Iemand nog suggesties?
Heb je het nou ook al met -u gedaan zoals ik gister aangaf? Want die zie ik nog steeds niet voorkomen in bovenstaande.
Ja, dat heb ik al meermaals gedaan:
husky01:~# date
do aug 23 05:48:41 CEST 2007
husky01:~# ntpdate -u ntp.xs4all.nl
23 Aug 05:48:55 ntpdate[20166]: step time server 194.109.22.18 offset 32049.9057
03 sec
husky01:~# date
do aug 23 05:48:59 CEST 2007
:-) :-) :-)
Kijk eens:
husky01:/# date
do aug 23 18:27:51 CEST 2007
Het staat goed! :-)
We draaien virtueel via xen. Xen heeft 1 basishost, dom0 en hier stond geen ntp op.
Oplossing: ntp op dom0 geïnstalleerd en base-config gedraait om zeker te zijn dat de goede tijdzone geselecteerd stond.
=> opgelost! :-D
BEDANKT IEDEREEN!