在 Debian 系统中,“日志时间不准”通常和 系统时钟(软件时钟) 或 硬件时钟(RTC) 有关。下面按常见场景给你一套完整校准方法。
date
查看系统时间。
sudo hwclock --show
查看硬件时钟(主板 CMOS 时间)。
对比两者是否一致。
Debian 10+ 默认带 systemd-timesyncd:
timedatectl
确保:
NTP service: active如果没有启用:
sudo timedatectl set-ntp true
sudo apt install ntpdate
sudo ntpdate cn.pool.ntp.org
常用 NTP 服务器:
cn.pool.ntp.org(国内)pool.ntp.orgsudo date -s "2026-01-21 15:30:00"
然后同步到硬件时钟:
sudo hwclock --systohc
sudo hwclock --systohc
sudo hwclock --hctosys
查看当前时区:
timedatectl
修改时区(如中国):
sudo timedatectl set-timezone Asia/Shanghai
如果是 rsyslog / journalctl 时间异常:
journalctl
确认是否和 date 一致。
重启日志服务:
sudo systemctl restart rsyslog
sudo systemctl restart systemd-journald
✅ 虚拟机:
✅ 双系统(Windows + Debian):
解决:
timedatectl set-local-rtc 1
如果你愿意,可以告诉我:
我可以给你更精确的方案。