學習一個 Linux 命令:ntpdate
作者:佚名
ntpddate 命令用于使用網絡計時協議(NTP)設置日期和時間。還可以用于同步時間,此命令需要具備root管理員權限才可執行。
命令簡介
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 ~]# date
- Sun Mar 28 13:09:22 EDT 2021
- [root@centos7 ~]# ntpdate 0.centos.pool.ntp.org
- 28 Mar 23:11:13 ntpdate[5516]: step time server 182.92.12.11 offset 36090.505486 sec
- [root@centos7 ~]# date
- Sun Mar 28 23:11:21 EDT 2021
- [root@centos7 ~]# ntpdate 0.centos.pool.ntp.org
- 28 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 -w
- 28 Mar 23:12:28 ntpdate[5520]: adjust time server 133.243.238.163 offset -0.013789 sec
責任編輯:龐桂玉
來源:
良許Linux