ROS(MikroTik RouterOS)自动设置校准/同步系统时间
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
阿里的Time服务器
time1.aliyun.com
time2.aliyun.com
time3.aliyun.com
time4.aliyun.com
time5.aliyun.com
time6.aliyun.com
Win系统自带的:
time.windows.com
time.nist.gov
苹果提供的授时服务器
time1.apple.com
time2.apple.com
time3.apple.com
time4.apple.com
time5.apple.com
time6.apple.com
time7.apple.com
Google提供的授时服务器
time1.google.com
time2.google.com
time3.google.com
time4.google.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=203.107.6.88 secondary-ntp=106.55.184.199\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
版权声明:
作者:RuyeNet
链接:https://www.iloveu.top/archives/130
来源:RuyeNet
文章版权归作者所有,未经允许请勿转载。

共有 0 条评论