# 查看当前实际时间(可打开浏览器搜索"当前时间")
# 假设当前正确时间是 2025-1-6 14:00:00

# 设置正确日期和时间
sudo date -s "2025-01-06 14:00:00"

# 验证时间已修正
date

同步网络时间(推荐)

# 安装时间同步工具
sudo apt update
sudo apt install ntpdate -y

# 同步网络时间(使用中国的时间服务器)
sudo ntpdate ntp.aliyun.com
# 或使用其他时间服务器
sudo ntpdate time.windows.com
sudo ntpdate ntp.ntsc.ac.cn # 中国科学院国家授时中心
sudo ntpdate time.nist.gov

# 设置时区(如果需要)
sudo timedatectl set-timezone Asia/Shanghai

启用自动时间同步

# 安装 systemd-timesyncd(现代Linux系统自带)
sudo apt install systemd-timesyncd -y

# 启用并启动时间同步服务
sudo timedatectl set-ntp true

# 查看时间同步状态
timedatectl status

# 查看详细同步信息
timedatectl timesync-status

验证时间同步

# 查看当前时间和NTP状态
timedatectl

# 输出示例应该显示:
# System clock synchronized: yes
# NTP service: active

 

 

 

 


登陆