问题:
Local time: Fri 2026-06-26 18:26:50 CST Universal time: Fri 2026-06-26 10:26:50 UTC RTC time: Fri 2026-06-26 18:26:50 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: no RTC in local TZ: yes DST active: n/a Warning: The system is configured to read the RTC time in the local time zone. This mode can not be fully supported. It will create various problems with time zone changes and daylight saving time adjustments. The RTC time is never updated, it relies on external facilities to maintain it. If at all possible, use RTC in UTC by calling 'timedatectl set-local-rtc 0'.
现在的状态:
硬件时钟(RTC time):18:26:50
系统本地时间(Local time):18:26:50 CST
UTC时间:10:26:50 UTC
问题所在:
硬件时钟里存的是18:26:50,但正确的北京时间应该是10:26:50(因为UTC时间10:26:50 + 8小时 = 18:26:50 CST)。
硬件时钟快了8个小时!它存的是CST时间(18:26:50),但系统以为是UTC时间,所以显示时又加了8小时,导致CST变成了18:26:50。
🔧 正确的解决方法
既然硬件时钟(RTC)里存的时间就是错的(快了8小时),我们需要先把硬件时钟改成正确的时间。
步骤1:先改回 UTC 模式(避免双重转换)
bash
sudo timedatectl set-local-rtc 0
步骤2:手动设置系统时间为正确的北京时间
当前正确的北京时间应该是10:26:50(因为UTC显示10:26:50):
bash
sudo date -s "2026-06-26 10:26:50"
步骤3:将正确的系统时间写入硬件时钟(UTC格式)
bash
sudo hwclock --systohc --utc
步骤4:验证
bash
timedatectl status date
期望输出:
text
Local time: Fri 2026-06-26 10:26:50 CST ← 正确的北京时间 Universal time: Fri 2026-06-26 02:26:50 UTC ← UTC时间 RTC time: Fri 2026-06-26 02:26:50 ← 硬件时钟存储UTC时间(02:26:50) Time zone: Asia/Shanghai (CST, +0800) RTC in local TZ: no ← 保持 no(推荐)