在 Debian 系统中,“校准时间戳”通常指的是同步系统时间(日期和时间)。下面按常见场景给你几种方法,从最简单到更严谨。
Debian 默认使用 systemd-timesyncd 做轻量级时间同步。
timedatectl
你会看到类似:
Local time: ...
Universal time: ...
RTC time: ...
System clock synchronized: yes
NTP service: active
sudo timedatectl set-ntp true
sudo systemctl restart systemd-timesyncd
编辑:
sudo nano /etc/systemd/timesyncd.conf
示例:
[Time]
NTP=ntp.aliyun.com
FallbackNTP=pool.ntp.org
然后:
sudo systemctl restart systemd-timesyncd
如果你需要更精确的 NTP(如服务器环境):
sudo apt update
sudo apt install ntp
安装后默认会从 Debian 配置的 NTP 服务器同步。
查看状态:
ntpq -p
sudo apt install chrony
sudo systemctl enable --now chrony
查看同步状态:
chronyc tracking
仅用于临时修正:
sudo date -s "2026-01-15 14:30:00"
写入硬件时钟(RTC):
sudo hwclock --systohc
如果是 VMware / KVM / VirtualBox:
echo 'GRUB_CMDLINE_LINUX="clock=host"' | sudo tee -a /etc/default/grub
sudo update-grub
date
timedatectl
如果你能说明:
我可以给你更精确的校准方案。