【问题标题】:Set the date in Beaglebone Black using ntp Debian 8.9使用 ntp Debian 8.9 在 Beaglebone Black 中设置日期
【发布时间】:2018-02-19 06:27:41
【问题描述】:

我一直在尝试在我的 Beaglebone Black 中设置正确的日期,但我尝试过的解决方案不是永久性的,每次我关闭 Beagle 电源并稍后再打开电源时,日期又是错误的。 所以这就是最初的样子:

root@beaglebone:~# date
Sat May 21 17:48:28 CDT 2016

然后我安装了ntp和ntpdate

root@beaglebone:~# apt-get install ntp ntpdate
Reading package lists... Done
Building dependency tree
Reading state information... Done
ntp is already the newest version.
ntpdate is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

之后我像这样编辑 ntp.conf 文件

# pool.ntp.org maps to about 1000 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.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org
...
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust
restrict 192.168.0.11 mask 255.255.255.0 nomodify notrap

下一步是

root@beaglebone:~# rm /etc/localtime
root@beaglebone:~# ln -s /usr/share/zoneinfo/America/Mexico_City /etc/localtime

在那之后我应该启用 ntp 服务

root@beaglebone:~# systemctl enable ntpdate.service
Failed to enable unit: No such file or directory

or

root@beaglebone:~# service ntpdate start
Failed to start ntpdate.service: Unit ntpdate.service not found.

我无法继续这样做,因为我没有 ntp.service 文件,所以我尝试了这个

root@beaglebone:~# timedatectl set-ntp true
root@beaglebone:~# timedatectl status
      Local time: Sat 2016-05-21 18:16:10 CDT
  Universal time: Sat 2016-05-21 23:16:10 UTC
        RTC time: Sat 2016-05-21 23:16:11
       Time zone: America/Mexico_City (CDT, -0500)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

root@beaglebone:~# nano /etc/systemd/timesyncd.conf
[Time]
NTP=0.north-america.pool.ntp.org 1.north-america.pool.ntp.org 2.north-america.pool.ntp.org 3.north-america.pool.ntp.org
FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org

最后我重新启动,似乎可以工作

root@beaglebone:~# timedatectl status
      Local time: Sun 2017-09-10 23:32:28 CDT
  Universal time: Mon 2017-09-11 04:32:28 UTC
        RTC time: Mon 2017-09-11 04:32:28
       Time zone: America/Mexico_City (CDT, -0500)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

但是话又说回来,关机后时间会自动回到 2016 年 5 月 21 日。我什至尝试使用 hwclock --set --date "date" --localtime 和 systohc 手动设置和同步时钟,但关机后结果是一样的。

我是否遗漏了什么或做错了什么?

我还在 /etc/adjtime 中将 'UTC' 更改为 'LOCAL',时间可以追溯到 2016 年 5 月。

谢谢。

【问题讨论】:

    标签: date debian beagleboneblack ntp


    【解决方案1】:

    试试这个:

    dpkg-重新配置 tzdata

    这应该有效。出现提示,您可以使用图形界面对其进行配置。就像美国一样容易进入。然后,您也可以选择您的时区。

    赛斯

    【讨论】:

    • 试过但没有用,它设置了时区,就像我在问题中发布的程序一样,但仍然在启动时重置。
    猜你喜欢
    • 1970-01-01
    • 2014-08-27
    • 1970-01-01
    • 1970-01-01
    • 2016-03-22
    • 2019-06-01
    • 1970-01-01
    • 2016-04-19
    • 1970-01-01
    相关资源
    最近更新 更多