当前位置: 首页 > 科技观察

学习一个Linux命令:ntpdate

时间:2023-03-15 13:30:56 科技观察

命令简介ntpdate命令用于使用网络时间协议(NTP)设置日期和时间。它也可以用来同步时间。该命令需要有root管理员权限才能执行。[root@centos7~]#ntpdate-bash:ntpdate:commandnotfound[root@centos7~]#yuinstallntpdate-y语法格式ntpdate[-b][-d][-s][-u][-aKeyid][-eAuthenticationDelay][-kKeyFile][-oVersion][-pSamples][-tTimeOut]Server...选项说明-aKeyid#使用Keyid对所有数据包进行认证-b#通过调用settimeofday子程序增加时钟的时间-d#SpecifydebuggingMode-eAuthenticationDelay#指定延迟认证处理的秒数。-oVersion#指定使用的NTP版本实现-pSamples#指定从每台服务器获取的样本数量-s#指定日志操作-tTimeOut#指定等待响应的时间-u#指定使用非特权端口来发送数据包应用示例同步时间[root@centos7~]#dateSunMar2813:09:22EDT2021[root@centos7~]#ntpdate0.centos.pool.ntp.org28Mar23:11:13ntpdate[5516]:steptimeserver182.92.12.11offset36090.505486sec[root@centos7~]#dateSunMar2823:11:21EDT2021[root@centos7~]#ntpdate0.centos.pool.ntp.org28Mar23:11:55ntpdate[5519]:steptimeserver182.92.12.11offset-0.722305sec[root@centos7~]#ntpdateasia.pool.ntp.org;hwclock-w28Mar23:12:28ntpdate[5520]:adjusttimeserver133.243.238.163offset-0.013789sec