Linux 日志时间“错乱”是一个比较常见的问题,通常不是日志系统本身坏了,而是时间来源不一致或配置不当导致的。下面按常见原因分类说明。
date 和 hwclock 显示时间不同date # 系统时间
hwclock --show # 硬件时间
# 用系统时间同步硬件时间
hwclock --systohc
# 或用硬件时间同步系统时间
hwclock --hctosys
timedatectl
timedatectl set-timezone Asia/Shanghai
Docker 示例:
-v /etc/localtime:/etc/localtime:ro
timedatectl status
systemctl status chronyd
# 或
systemctl status ntpd
systemctl enable --now chronyd
chronyc sources
date -stimedatectl
date
hwclock --show
journalctl -n 20 --since "10 min ago"
如果你能提供:
我可以更精确地判断是哪一种“错乱”。