当前位置: 首页 > Linux

每天学一个Linux命令(96):ntpdate

时间:2023-04-06 23:34:35 Linux

命令介绍ntpddate命令用于使用网络时间协议(NTP)设置日期和时间。它也可以用来同步时间。该命令需要有root管理员权限才能执行。[root@centos7~]#ntpdate-bash:ntpdate:commandnotfound[root@centos7~]#yuminstallntpdate-y语法格式ntpdate[-b][-d][-s][-u][-aKeyid][-eAuthenticationDelay][-kKeyFile][-oVersion][-pSamples][-tTimeOut]Server...选项说明-aKeyid#使用Keyid对所有数据包进行认证-b#通过调用settimeofday子程序增加时钟时间-d#指定调试方式-eAuthenticationDelay#指定延迟认证处理的时间,以秒为单位。-oVersion#指定用于执行的NTP版本-pSamples#指定从每个服务器获取的样本数量-s#指定日志操作-tTimeOut#指定等待响应的时间-u#指定使用非特权端口来发送数据包应用示例同步时间[root@centos7~]#dateSunMar2813:09:22EDT2021[root@centos7~]#ntpdate0.centos.pool.ntp.org28Mar23:11:13ntpdate[5516]:步骤时间服务器182.92.12.11偏移36090.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]:调整时间服务器133.243.238.163偏移量-0.013789秒