【树莓派】树莓派网络对时间,时间调整

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

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

树莓派没有电池,断电后无法保存时间。树莓派默认安装了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

在下面添加以下内容,添加之后按Ctrl+X保存退出。

server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
 

重启ntp服务

sudo /etc/init.d/ntp restart
原文地址:https://www.cnblogs.com/haochuang/p/6264969.html