方案 1:强制使用 NTP 同步(忽略硬件时钟)
操作步骤
确保 NTP 服务持续运行:
bash
sudo systemctl stop systemd-timesyncd # 停止旧服务
sudo apt install chrony # 安装更稳定的 NTP 工具
sudo systemctl enable --now chronyd
或者sudo systemctl enable --now chrony
配置 chrony 使用阿里云服务器:
bash
sudo nano /etc/chrony/chrony.conf
或者sudo vim /etc/chrony/chrony.conf
添加或修改为:
server ntp.aliyun.com iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
- 保存文件并重启 Chrony 服务
bash
sudo systemctl restart chrony
验证同步状态:
bash
chronyc sources -v
若显示 ^*
标记,说明同步成功
优势
无需硬件时钟支持,完全依赖网络时间(适合始终联网的设备)。
比 ntpdate 更精确,支持平滑时间调整。