ruby-on-rails - 服务器上的当前时间与实际时间相差 7 分钟
问题描述
有谁知道这怎么会发生?我的服务器比每个 google 的实时时间慢 7 分钟(与用户设备/手机上显示的实时时间相匹配)。
我在数字海洋上使用Ubuntu服务器。
每个服务器上的当前时间
ruby
(在 irc 中):Time.zone.now => Fri, 27 Jul 2018 09:19:12 CDT -05:00
每个服务器上的当前时间
shell
(在 irc 中):`date` => "Fri Jul 27 14:19:17 UTC 2018\n"
每个 shell(直接)在服务器上的当前时间:
$ date Fri Jul 27 14:19:28 UTC 2018
我怎么休息七分钟?我已经让这台服务器运行了 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
解决方案
推荐阅读
- python-3.x - TypeError: 参数应该是字节类对象或 ASCII 字符串,而不是“二进制”
- ios - iOS推送通知:当应用程序被快速终止或终止时如何存储推送通知有效负载?
- python - 使用正则表达式按顺序匹配多个单词
- c++ - 如何在 C++ 中正确声明/分配变量的值
- python - 如何在 numpy 中切片网格点数组以保持顺序?
- python - 如何在 django 的 url 上放置搜索查询?
- debian-based - 为什么我不能使用命令行更新我无尽的操作系统?它带来了这个错误。我的sources.list 有问题吗?
- django - Django,有条件地覆盖模板块
- html - 即使在 CSS 文件中格式化按钮也不会按应有的方式显示
- java - 使用 Dom 解析器加载 XML 文件时出现问题