命令简介

ntpddate 命令用于应用网络计时协定(NTP)设置日期和工夫。还能够用于同步工夫,此命令须要具备root管理员权限才可执行。

[root@centos7 ~]# ntpdate-bash: ntpdate: command not found[root@centos7 ~]# yum install ntpdate -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 ~]# dateSun Mar 28 13:09:22 EDT 2021[root@centos7 ~]# ntpdate 0.centos.pool.ntp.org28 Mar 23:11:13 ntpdate[5516]: step time server 182.92.12.11 offset 36090.505486 sec[root@centos7 ~]# dateSun Mar 28 23:11:21 EDT 2021[root@centos7 ~]# ntpdate 0.centos.pool.ntp.org28 Mar 23:11:55 ntpdate[5519]: step time server 182.92.12.11 offset -0.722305 sec[root@centos7 ~]# ntpdate asia.pool.ntp.org;hwclock -w28 Mar 23:12:28 ntpdate[5520]: adjust time server 133.243.238.163 offset -0.013789 sec