CentOS 系统时间不对,一般不是“单一原因”,而是系统配置、时区、硬件时钟、NTP 服务等因素共同作用的结果。下面按最常见原因 → 排查方法 → 解决方案给你一个完整说明。
系统时间是对的,但时区不对,看起来“慢/快 8 小时”。
检查:
timedatectl
看:
Time zoneRTC in local TZ常见错误:
Asia/ShanghaiCentOS 启动时会从主板时钟读取时间。
检查:
hwclock
date
如果两者差很多,就说明硬件时间不对。
系统不会自动校时,时间会逐渐漂移。
检查:
timedatectl status
看:
NTP enabled: no
只改了系统时间,重启后又恢复错误时间。
| 版本 | 时间服务 |
|---|---|
| CentOS 7 | ntpd / chronyd |
| CentOS 8+ | chronyd(默认) |
date
timedatectl
✅ 正确示例(中国):
Time zone: Asia/Shanghai (CST, +0800)
RTC in local TZ: no
timedatectl set-timezone Asia/Shanghai
yum install -y ntp
systemctl enable ntpd
systemctl start ntpd
yum install -y chrony
systemctl enable chronyd
systemctl start chronyd
确认:
chronyc sources
ntpdate ntp.aliyun.com
或
chronyc makestep
hwclock --systohc
如果你是 VMware / KVM / VirtualBox:
yum install open-vm-tools
systemctl enable vmtoolsd
systemctl start vmtoolsd
yum install qemu-guest-agent
systemctl enable qemu-guest-agent
systemctl start qemu-guest-agent
date
timedatectl
hwclock
chronyc tracking
把你看到的结果贴出来,我可以直接帮你判断是哪一步的问题。
CentOS 时间不对,90% 是时区 + 没开 NTP + 虚拟机时间漂移。
如果你愿意,可以告诉我:
cat /etc/centos-release)我可以给你精确到命令级的解决方案。