树莓派(Raspberry Pi)日期时间不准的修正方法

在树莓派上,打date命令可以看到系统的日期时间:

 后面的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

 

posted on 2014-08-31 14:24  InfoPi  阅读(20938)  评论(0编辑  收藏  举报

导航