最新消息:码丁实验室,一站式儿童编程学习产品,寻地方代理合作共赢,微信联系:leon121393608。

树莓派3-配置-系统时间

Raspberry Pi 少儿编程 1752浏览 0评论

码丁实验室,一站式儿童编程学习产品,寻地方代理合作共赢,微信联系:leon121393608。

配置系统时间

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

osmc@osmc:~$ date
Sun Aug 28 07:38:06 UTC 2016

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

sudo ntpd -s -d

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

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

您必须 登录 才能发表评论!