Linux
linux上錯誤的硬體時間
我的 debian 伺服器上沒有正確的硬體時間:
root@server[09:48]:date Tue Dec 22 09:48:52 EST 2015 root@server[09:48]:date -u Tue Dec 22 14:48:54 UTC 2015 root@server[09:48]:cat /etc/timezone Europe/Paris root@server[09:48]:hwclock -w --utc --debug hwclock from util-linux 2.25.2 Using the /dev interface to the clock. Last drift adjustment done at 1450795502 seconds after 1969 Last calibration done at 1450795502 seconds after 1969 Hardware clock is on UTC time Assuming hardware clock is kept in UTC time. Waiting for clock tick... ...got clock tick Time read from Hardware Clock: 2015/12/22 14:46:18 Hw clock time : 2015/12/22 14:46:18 = 1450795578 seconds since 1969 1450795578.500007 is close enough to 1450795578.500000 (0.000007 < 0.001000) Set RTC to 1450795578 (1450795578 + 0; refsystime = 1450795578.000000) Setting Hardware Clock to 14:46:18 = 1450795578 seconds since 1969 ioctl(RTC_SET_TIME) was successful. Not adjusting drift factor because it has been less than a day since the last calibration. root@server[09:48]:cat /etc/adjtime 0.000000 1450795578 0.000000 1450795578 UTC
我該怎麼辦?
root@server[10:04]:vi /etc/ntp.conf 18 # pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will 19 # pick a different set every time it starts up. Please consider joining the 20 # pool: <http://www.pool.ntp.org/join.html> 21 server ntp.ubuntu.com prefer 22 server ntp2.jussieu.fr 23 server 0.fr.pool.ntp.org 24 server 0.europe.pool.ntp.org root@server[10:04]:ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== golem.canonical 170.224.124.217 2 u 5 64 1 2.045 -0.616 0.000 horlogegps.rese 10.3.128.189 2 u 4 64 1 9.276 -0.195 0.000 62-210-204-185. 193.190.230.65 2 u 3 64 1 9.696 2.003 0.000 static.140.107. 192.53.103.108 2 u 2 64 1 16.062 1.159 0.000
您的時區設置為 EST(東部標準時間),這是紐約的時區,而不是巴黎的時區。巴黎時間為 CET(中歐時間)。
您必須首先正確設置時區,這可以通過多種方式完成:
- 使用命令
tzselect
- 使用命令
dpkg-reconfigure tzdata
- 輸入
TZ='Europe/Paris'; export TZ
您的~/.bash_profile
,~/.bash_login
, 或~/.profile
時區正確後,您可以設置正確的時間(如有必要)。