首页>>帮助中心>>当ntpdate失效时-Linux系统时间校准的备用策略

当ntpdate失效时-Linux系统时间校准的备用策略

2025/7/31 23次

问题主要出现在同步服务器时间时报错 :

安装chrony

# CentOS/RHEL

sudo yum install chrony# Ubuntu/Debiansudo apt-get install chrony

配置和使用

# 启动chrony服务sudo systemctl start chronydsudo systemctl enable chronyd

# 手动同步时间sudo chrony sources -vsudo chronyc makestep

2. 使用timedatectl(systemd系统)


# 查看时间状态timedatectl status# 启用NTP同步sudo timedatectl set-ntp true

# 设置时区sudo timedatectl set-timezone Asia/Shanghai

3. 使用sntp命令

# 安装sntpsudo yum install ntp # 或 sudo apt-get install sntp

# 同步时间sudo sntp -s time.nist.govsudo sntp -s pool.ntp.org

4. 手动设置系统时间5

# 设置系统时间sudo date -s "2025-07-31 10:30:00"

# 将系统时间写入硬件时钟sudo hwclock --systohc

5. 解决ntpdate常见报错

防火墙问题

# 临时关闭防火墙测试sudo systemctl stop firewalld # CentOS/RHELsudo ufw disable

# Ubuntu# 或者开放NTP端口(UDP 123)sudo firewall-cmd --add-service=ntp --permanent

版权声明

    声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们996811936@qq.com进行处理。