介NTP 是网络时间协议(Network Time
Protocol),它用来同步网络设备【如计算机、手机】的时间的协议。为我们提供准确时间。因为我们的手表、手机、电脑等设备,经常会跑着跑着时间就出现了误差,或快或慢的少几秒,时间长了甚至误差过分钟。对于ROS来讲当你的ROS服务器主板电池没电或断电时间错误时,可能会比较需要这个脚本,用来从网络上校准系统时间。
操作菜单:system- ntp client
v6.x脚本:
/system clock set time-zone-name=Asia/Shanghai :global ntpipnewp ([:resolve ntp.aliyun.com]) /system ntp client set primary-ntp=$ntpipnewp :global ntpipnews ([:resolve time1.cloud.tencent.com]) /system ntp client set secondary-ntp=$ntpipnews
*阿里云的NTP服务器:
ntp1.aliyun.com ntp2.aliyun.com ntp3.aliyun.com ntp4.aliyun.com ntp5.aliyun.com ntp6.aliyun.com ntp7.aliyun.com
*腾讯云的NTP服务器:
time1.cloud.tencent.com time2.cloud.tencent.com time3.cloud.tencent.com time4.cloud.tencent.com time5.cloud.tencent.com
每月通过域名更新一次ntp server。v6.x用v7.x不需要
/sys scheduler remove ntp-server-update /system scheduler add interval=4w2d name=ntp-server-update on-event="/system clock set time-zone-name=Asia/Shanghai\r\ \n/system ntp client set enabled=yes primary-ntp=120.25.115.20 secondary-ntp=203.107.6.88\r\ \n:global ntpipnewp ([:resolve ntp.aliyun.com]) \r\ \n/system ntp client set primary-ntp=\$ntpipnewp\r\ \n:global ntpipnews ([:resolve time1.cloud.tencent.com]) \r\ \n/system ntp client set secondary-ntp=\$ntpipnews\r\ \n" start-date=jan/01/1990 \ start-time=03:00:00
2023-12-13T11:46:19
2023-12-13T11:48:22
2024-01-02T09:07:42
2024-01-02T09:07:20
2024-01-02T09:06:50
2024-01-02T09:06:26
2024-01-02T09:06:01
2024-01-02T09:05:20
2024-01-02T09:04:49
2024-01-02T09:04:17