< 返回新闻公共列表
当ntpdate失效时-Linux系统时间校准的备用策略
发布时间:2025/8/1 10:07:48
问题主要出现在同步服务器时间时报错 :
安装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