Ubuntu 系统时钟与时区(systemd-timesyncd)
讲清 Ubuntu 默认时间同步机制 systemd-timesyncd 与 chrony 的分工、时区设置命令、双系统下时钟漂移的处理思路。
结论先行
Ubuntu 默认用 systemd-timesyncd 做 NTP 同步(轻量、够用),需要更高精度/多服务器场景可换 chrony。时区用 timedatectl 一行改完;双系统下「重启后时钟漂移」通常要改 Linux 侧的本地时间设置。
查看与设置
timedatectl # 当前时间、时区、同步状态
sudo timedatectl set-timezone Asia/Shanghai
timedatectl status | grep -i ntp # NTP 是否已同步
时间同步的两个组件
| 组件 | 定位 | 服务名 |
|---|---|---|
| systemd-timesyncd | 默认,单客户端、SNTP | systemd-timesyncd |
| chrony | 更精确、可做服务器 | chrony |
sudo systemctl status systemd-timesyncd
sudo apt install -y chrony # 需要时再装
sudo systemctl enable --now chrony
chronyc tracking # 看漂移
两个组件同时开着会抢同一职责;换 chrony 后停掉 timesyncd,反之亦然。
双系统时钟差 8 小时的处理
现象:Windows 侧读 Linux 时偏移 8 小时,或反之。根因是 Linux 默认存 UTC、Windows 默认存本地时间,两系统对硬件时钟的解释不一致。解法二选一:
- 让 Linux 改存本地时间:
sudo timedatectl set-local-rtc 1(重启生效) - 让 Windows 改存 UTC(注册表
RealTimeIsUniversal)
选哪种视你 Windows 侧配置习惯而定,改完观察一两次重启确认。
桌面与服务器行为一致,基于 Ubuntu 索引页 条目(桌面版、服务器版)。