Linux ntp ntpdate
简介
ntpdate指令通过轮询指定为服务器参数的网络时间协议(NTP)服务器来设置本地日期和时间,从而确定正确的时间。此命令的适用范围:RedHat、RHEL、Ubuntu、CentOS、Fedora。
安装
1. 中国NTP服务器
2. 安装ntp、ntpdate
yum install -y ntp
yum install -y ntpdate
3. 配置ntp
# 编辑NTP配置文件
vim /etc/ntp.conf
# 注释配置文件中原有的NTP服务器,并在其中添加自己所需的NTP服务器地址
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
server cn.ntp.org.cn iburst
4. 配置自启服务
systemctl enable ntpd.service
5. 启动ntp
systemctl start ntpd
6. 检查ntp运行状态
systemctl status ntpd
ntpstat
watch ntpq -p
7. 同步网络时间
# 中国
ntpdate -u cn.ntp.org.cn
# 中国教育网
ntpdate -u edu.ntp.org.cn
# 阿里云
ntpdate -u 120.25.108.11
ntpdate -u 182.92.12.11
ntpdate -u 203.107.6.88
ntpdate -u 120.25.115.20
ntpdate -u ntp1.aliyun.com
# 中国香港
ntpdate -u hk.ntp.org.cn
# 中国台湾
ntpdate -u tw.ntp.org.cn
本文作者:逢生博客
本文链接:https://www.cnblogs.com/wufengsheng/p/16297967.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步