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

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

admin2015年6月28日  7 Comments

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

311415114852764
(后面的CST表示中国标准时间)

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

1

sudo ntpd -s -d

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

1

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

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

打开ntp服务的配置文件

1

sudo nano /etc/ntp.conf

找到这两行

1

2

# You do need to talk to an NTP server or two (or three).

# server ntp.your-provider.example

在下面添加以下内容,是一些亲测可用的ntp服务器。第一行最后的perfer表示优先使用此服务器,也就是复旦大学的ntp服务器。添加之后按Ctrl+X保存退出。

1

2

3

4

5

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服务

1

sudo /etc/init.d/ntp restart

via

本文来自:树莓派实验室
链接地址:http://shumeipai.nxez.com/2015/06/28/raspberry-pi-date-and-time-correction-method-allowed.html

猜你喜欢

转载自blog.csdn.net/qq_37967635/article/details/83095681