在 CentOS 上“校对时间戳”通常指同步系统时间(时钟),让系统时间与标准时间一致。下面按常见场景说明。
yum install -y chrony
systemctl start chronyd
systemctl enable chronyd
chronyc -a makestep
chronyc tracking
编辑:
vi /etc/chrony.conf
常见 NTP 服务器:
server ntp.aliyun.com iburst
server time1.cloud.tencent.com iburst
修改后重启:
systemctl restart chronyd
yum install -y ntp
systemctl start ntpd
systemctl enable ntpd
ntpdate ntp.aliyun.com
若提示
ntpdate: the NTP socket is in use,先停 ntpd:systemctl stop ntpd ntpdate ntp.aliyun.com systemctl start ntpd
date -s "2026-01-15 10:30:00"
写入硬件时钟:
hwclock --systohc
date
date +%s # 秒级时间戳
date +%s%3N # 毫秒级
查看时区:
timedatectl
修改时区(如上海):
timedatectl set-timezone Asia/Shanghai
chronyc makestep 强制校正如果你能说明是 CentOS 几、物理机/虚拟机、是否离线环境,我可以给你更精确的方案。