Debian 时间戳更新与同步步骤
一 前置检查
timedatectl statustimedatectl list-timezones,便于后续设置正确时区。二 方法一 使用 systemd-timesyncd(系统自带,轻量)
sudo apt update && sudo apt install systemd-timesyncdsudo timedatectl set-timezone Asia/Shanghaisudo nano /etc/systemd/timesyncd.conf
NTP=ntp7.aliyun.comNTP=ntp6.aliyun.comNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.orgsudo systemctl restart systemd-timesyncd.servicesudo systemctl enable systemd-timesyncd.servicetimedatectl status(查看 System clock synchronized: yes)timedatectl timesync-status(查看同步源与偏差)三 方法二 使用 NTP 或 Chrony(持续守时,适合服务器)
sudo apt update && sudo apt install ntp/etc/ntp.conf,添加或修改:
server 0.debian.pool.ntp.org iburstserver 1.debian.pool.ntp.org iburstsudo systemctl restart ntpsudo systemctl enable ntpntpq -p(查看对时状态与同步源)timedatectl status(确认已同步)sudo apt update && sudo apt install chrony/etc/chrony/chrony.conf,添加:
server ntp7.aliyun.com iburstserver ntp6.aliyun.com iburstsudo systemctl restart chronydsudo systemctl enable chronydchronyc tracking(查看来源与偏差)timedatectl status四 方法三 一次性手动校时(应急,不替代长期同步)
sudo apt install ntpdate -ysudo ntpdate -s pool.ntp.orgsudo ntpdate -s ntp.sjtu.edu.cnsudo hwclock --systohc五 常见问题与建议
sudo timedatectl set-timezone Asia/Shanghai 再检查。