服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - 学习一个 Linux 命令:ntpdate

学习一个 Linux 命令:ntpdate

2021-04-11 22:02良许Linux Linux

ntpddate 命令用于使用网络计时协议(NTP)设置日期和时间。还可以用于同步时间,此命令需要具备root管理员权限才可执行。

学习一个 Linux 命令:ntpdate

命令简介

 

ntpddate 命令用于使用网络计时协议(NTP)设置日期和时间。还可以用于同步时间,此命令需要具备root管理员权限才可执行。

  1. [root@centos7 ~]# ntpdate 
  2. -bash: ntpdate: command not found 
  3. [root@centos7 ~]# yum install ntpdate -y 

语法格式

 

ntpdate [ -b] [ -d] [ -s] [ -u] [ -aKeyid] [ -eAuthenticationDelay] [ -kKeyFile] [ -oVersion] [ -pSamples] [ -tTimeOut] Server...

选项说明 

 

  1. -aKeyid  #使用 Keyid 来认证全部数据包 
  2. -b       #通过调用 settimeofday 子例程来增加时钟的时间 
  3. -d       #指定调试方式 
  4. -eAuthenticationDelay   #指定延迟认证处理的时间秒数。 
  5. -oVersion      #指定使用的 NTP 版本实现 
  6. -pSamples      #指定从每个服务器获取的样本的数目 
  7. -s          #指定日志操作 
  8. -tTimeOut   #指定等待响应的时间 
  9. -u          #指定使用无特权的端口发送数据包 

应用举例

 

同步时间

  1. [root@centos7 ~]# date 
  2. Sun Mar 28 13:09:22 EDT 2021 
  3. [root@centos7 ~]# ntpdate 0.centos.pool.ntp.org 
  4. 28 Mar 23:11:13 ntpdate[5516]: step time server 182.92.12.11 offset 36090.505486 sec 
  5. [root@centos7 ~]# date 
  6. Sun Mar 28 23:11:21 EDT 2021 
  7.  
  8. [root@centos7 ~]# ntpdate 0.centos.pool.ntp.org 
  9. 28 Mar 23:11:55 ntpdate[5519]: step time server 182.92.12.11 offset -0.722305 sec 
  10. [root@centos7 ~]# ntpdate asia.pool.ntp.org;hwclock -w 
  11. 28 Mar 23:12:28 ntpdate[5520]: adjust time server 133.243.238.163 offset -0.013789 sec 

原文地址:https://mp.weixin.qq.com/s/_Dxrgn7-VGVZbR9bWJ4Ogw

延伸 · 阅读

精彩推荐