我一直在尝试在我的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.
我无法继续使用thas因为我没有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月。
感谢。
答案 0 :(得分:1)
试试这个:
dpkg-reconfigure tzdata
这应该有效。出现提示,您可以使用图形界面对其进行配置。它就像美国一样容易进入。然后,你也可以选择你的时区。
赛斯