首页 > 解决方案 > 服务器上的当前时间与实际时间相差 7 分钟

问题描述

有谁知道这怎么会发生?我的服务器比每个 google 的实时时间慢 7 分钟(与用户设备/手机上显示的实时时间相匹配)。

我在数字海洋上使用Ubuntu服务器。

我怎么休息七分钟?我已经让这台服务器运行了 4 年以上。我认为这发生在最近,它导致服务器和终端设备之间的同步问题。

编辑:@ 9:39 AM CDT 每个谷歌

我刚刚发现timedatectl。看来我的服务器时间没有同步:

$ timedatectl
Local time: Fri 2018-07-27 14:32:30 UTC
Universal time: Fri 2018-07-27 14:32:30 UTC
Timezone: Etc/UTC (UTC, +0000)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a

编辑:@ 9:47 AM CDT 每个谷歌

我刚刚安装NTP

$ sudo apt-get update
$ sudo apt-get install ntp

timedatectl仍然显示 7 分钟关闭,但显示NTP synchronized: yes

$ timedatectl
Local time: Fri 2018-07-27 14:39:38 UTC
Universal time: Fri 2018-07-27 14:39:38 UTC
Timezone: Etc/UTC (UTC, +0000)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

编辑:@ 9:50 AM CDT 每个谷歌

timedatectl现在看起来是正确的,但说NTP synchronized: no again:

$ timedatectl
Local time: Fri 2018-07-27 14:50:12 UTC
Universal time: Fri 2018-07-27 14:50:12 UTC
Timezone: Etc/UTC (UTC, +0000)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a

标签: ruby-on-railsrubyshellubuntuntp

解决方案


应始终使用NTP与 NTP 服务器同步时间。

Modern Ubuntu 建议chrony用于此目的。我总是用ntpd.


推荐阅读