在 Ubuntu 中,“时间戳”通常和**系统时间(日期时间)**以及 硬件时钟(RTC) 有关。下面按常见场景教你如何校准。
# 查看时间同步状态
timedatectl status
# 开启自动时间同步
sudo timedatectl set-ntp true
如果 System clock synchronized: yes,说明已校准。
sudo apt update
sudo apt install chrony
sudo systemctl enable --now chrony
查看同步状态:
chronyc tracking
sudo date -s "2026-01-21 15:30:00"
sudo hwclock --systohc
sudo hwclock --show
sudo hwclock --systohc
sudo hwclock --hctosys
如果时间戳“不对”,很可能是时区问题:
# 查看当前时区
timedatectl
# 设置时区(示例:中国)
sudo timedatectl set-timezone Asia/Shanghai
date +%s # Unix 时间戳(秒)
date # 当前系统时间
systemctl status systemd-timesyncd
journalctl -u systemd-timesyncd
open-vm-tools / hyperv-daemons如果你是指:
可以告诉我具体场景,我可以给你更精确的方案。