首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何确定几年后的日期?

如何确定几年后的日期?
EN

Server Fault用户
提问于 2016-07-08 22:18:40
回答 1查看 2.3K关注 0票数 2

我的服务器在未来的2027年:

代码语言:javascript
复制
# sudo ntpdate ptbtime1.ptb.de
9 Jul 00:04:01 ntpdate[10000]: step time server 192.53.103.108 offset -353547847.989546 sec
# date
Di 21. Sep 23:48:18 CEST 2027
# hwclock
Sa 09 Jul 2016 02:03:56 CEST  -0.234935 Sekunden

在未来十多年里,这一趋势是巨大的。我不能用“正常”的重新设置来改变漂移。我已经读过几篇文章了,我尝试了很多东西,比如ntpdate -b、ntpd -gq或tinker恐慌0。我更改时区,并尝试手动设置日期/时间。什么都没用。我该怎么纠正呢?有人能帮帮我吗?我正在Kubuntu14.04LTS上运行(GNU/Linux3.13.0-66-通用i686)

==================================================================

这会不会引起问题?

代码语言:javascript
复制
# sudo service ntp stop
 * Stopping NTP server ntpd                                                                             [ OK ]
# ntpq -p
ntpq: read: Connection refused

==================================================================

代码语言:javascript
复制
# sudo service ntp stop
 * Stopping NTP server ntpd                                                                                      [ OK ]
# sudo ntpd -gq
ntpd: time set -353547849.485594s
# sudo service ntp start
 * Starting NTP server ntpd                                                                                      [ OK ]
# date
Mi 22. Sep 11:39:09 CEST 2027

====================================================================

请注意,对于ntpd来说“太远”有多远?它能通过突然跳到重物上到达那里吗?这能被推翻吗?“根据手册页ntpd将无法工作,如果您的时钟是超过1000秒关闭。

====================================================================

我试着手动改变它:

代码语言:javascript
复制
# date
Mi 22. Sep 11:32:09 CEST 2027
# sudo date --set="2016-07-09 11:50:59.990"
Sa 9. Jul 11:50:59 CEST 2016
# date
Mi 22. Sep 11:35:08 CEST 2027

==================================================================

我可以用“一年”的日期来增加漂移。但我不能减少。

=========================================================================

它不起作用:

代码语言:javascript
复制
# sudo service ntp stop
 * Stopping NTP server ntpd                                                            [ OK ]
# sudo ntpdate-debian
 9 Jul 14:56:52 ntpdate[3684]: step time server 131.188.3.220 offset -353547850.182477 sec
# sudo service ntp start
 * Starting NTP server ntpd                                                            [ OK ]
# date
Mi 22. Sep 14:41:25 CEST 2027

更新:我不够耐心。我不得不再等一会儿,但巨大的漂移仍然存在。

=====================================================

/etc/ntp.conf

代码语言:javascript
复制
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
tinker panic 0

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
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

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server ntp.ubuntu.com
server pool.ntp.org
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

# Use Ubuntu's ntp server as a fallback.
server ntp.ubuntu.com

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
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

=====================================================

我也试过

代码语言:javascript
复制
# sudo sntp -s ntp.ubuntu.com
22 Sep 12:53:56 sntp[17210]: Started sntp
2027-09-22 12:53:56.128427 (-0100) -353533451.192434 +/- 0.049652 secs
2027-09-22 12:53:56.155758 (-0100) -176766725.596156 +/- 0.024307 secs
2027-09-22 12:53:56.183422 (-0100) -265150088.380065 +/- 0.049652 secs
# date
Mi 22. Sep 12:54:01 CEST 2027

=====================================================

下面是ntpdate之后的日期-debian:

代码语言:javascript
复制
# date
Mi 22. Sep 12:54:40 CEST 2027
# sudo ntpdate-debian -s ntp.ubuntu.com && date
Sa 9. Jul 17:15:02 CEST 2016
# date
Mi 22. Sep 12:59:20 CEST 2027
# sudo ntpdate-debian -s ntp.ubuntu.com && date && date && date
Mi 22. Sep 13:00:21 CEST 2027
Mi 22. Sep 13:00:21 CEST 2027
Mi 22. Sep 13:00:21 CEST 2027
# sudo ntpdate-debian -s ntp.ubuntu.com && date && date && date
Sa 9. Jul 17:16:44 CEST 2016
Mi 22. Sep 13:00:55 CEST 2027
Mi 22. Sep 13:00:55 CEST 2027

=====================================================

已删除的漂流文件:

代码语言:javascript
复制
sudo service ntp stop
rm /etc/adjtime
rm /var/lib/ntp/ntp.drift
shutdown –h now

在重新启动/var/lib/ntp/ntp之后,漂移为空。/etc/adjtime是

代码语言:javascript
复制
0.000000 1821611426 0.000000
1821611426
UTC

日期/时间仍然相同。漂移藏在哪里?

========================================================

溶液

迈克尔·汉普顿:

我停止了ntp (使用ps –aux | grep ntp检查)并使用了hwclock –s

代码语言:javascript
复制
# sudo service ntp stop 
* Stopping NTP server ntpd                                                                                         [ OK ]
# sudo hwclock --set --date="7/9/16 18:37:30"
# hwclock
Sa 09 Jul 2016 18:37:34 CEST  -0.047338 Sekunden
# hwclock -s
# hwclock
Sa 09 Jul 2016 18:37:47 CEST  -0.984834 Sekunden
# hwclock
Sa 09 Jul 2016 18:38:01 CEST  -0.219219 Sekunden
# date
Mi 22. Sep 00:24:34 CEST 2027
# date
Mi 22. Sep 00:29:32 CEST 2027
# date
Mi 22. Sep 00:33:49 CEST 2027

我必须重新启动,我必须纠正文件系统,因为它抱怨最后一次文件系统检查是在未来。

感谢所有帮助我的人,也非常特别地感谢迈克尔!

EN

回答 1

Server Fault用户

发布于 2016-07-08 23:13:06

由于您正在运行基于Debian的发行版,请尝试以下操作:

代码语言:javascript
复制
sudo service ntp stop
sudo ntpdate-debian
sudo service ntp start
票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/788796

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档