Leif160519的blog Leif160519的blog

——————

目录
树莓派日期时间不准的修正方法
/    

树莓派日期时间不准的修正方法


在树莓派上,打date命令可以看到系统的日期时间:
image.png
后面的CST表示中国标准时间

注意:
树莓派没有电池,断电后无法保存时间。
树莓派默认安装了NTP(Network Time Protocol)服务来获取互联网上ntp服务器提供的时间。
如果这个时间不准,可以用这个命令校准一下:

sudo ntpd -s -d

如果还是不准,就用这个命令强制设置

我就碰到这种情况:时间在走,但无论重启系统还是重启ntp服务都无法更新日期和时间

sudo date  --s="2014-08-31 14:42:00"

最后,添加一些国内可用的ntp服务器,如果你的时间正常,可以不做这些设置。
打开ntp服务的配置文件

sudo nano /etc/ntp.conf

找到这两行

# You do need to talk to an NTP server or two (or three).
# server ntp.your-provider.example

在下面添加以下内容,是一些亲测可用的ntp服务器

第一行最后的perfer表示优先使用此服务器,也就是复旦大学的ntp服务器

添加之后按Ctrl+X保存退出

server ntp.fudan.edu.cn iburst perfer
server time.asia.apple.com iburst
server asia.pool.ntp.org iburst
server ntp.nict.jp iburst
server time.nist.gov iburst

重启ntp服务

sudo /etc/init.d/ntp restart

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题树莓派日期时间不准的修正方法
作  者Leif160519
出  处https://github.icu/articles/2019/08/27/1566888559005.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!