修正系统时间# 查看当前实际时间(可打开浏览器搜索"当前时间")
# 假设当前正确时间是 2025-1-6 14:00:00
# 设置正确日期和时间
Code:
sudo date -s "2025-01-06 14:00:00"
# 验证时间已修正
2. 同步网络时间(推荐)# 安装时间同步工具
Code:
sudo apt update
sudo apt install ntpdate -y
# 同步网络时间(使用中国的时间服务器)
Code:
sudo ntpdate ntp.aliyun.com
# 或使用其他时间服务器
Code:
sudo ntpdate time.windows.com
sudo ntpdate ntp.ntsc.ac.cn # 中国科学院国家授时中心
sudo ntpdate time.nist.gov
# 设置时区(如果需要)
Code:
sudo timedatectl set-timezone Asia/Shanghai
3. 启用自动时间同步# 安装 systemd-timesyncd(现代Linux系统自带)
Code:
sudo apt install systemd-timesyncd -y
# 启用并启动时间同步服务
Code:
sudo timedatectl set-ntp true
# 查看时间同步状态
# 查看详细同步信息
Code:
timedatectl timesync-status