# 查看可用時區
ls /usr/share/zoneinfo/
# 設定為上海/北京時間 (永久)
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 或使用 timedatectl (systemd)
timedatectl set-timezone Asia/Shanghai
# 查看系統時間
date
# 設定系統時間 (格式: MMDDhhmmYYYY.ss)
date 091713272003.30
# 查看硬體時間
hwclock --show
# 或 clock --show
# 設定硬體時間
hwclock --set --date="09/17/2003 13:26:00"
# 硬體 → 系統 (啟動時自動執行)
hwclock --hctosys
# 系統 → 硬體 (關機時自動執行)
hwclock --systohc
Red Hat/CentOS:system-config-date 或 redhat-config-time (舊版)。
Ubuntu:gnome-control-center datetime。
yum install chrony
systemctl enable --now chronyd
# 編輯 /etc/chrony.conf 指定伺服器
server time.google.com iburst
server time.cloudflare.com iburst
systemctl restart chronyd
chronyc sources -v
chronyc tracking
yum install ntp
systemctl enable --now ntpd
# 編輯 /etc/ntp.conf
server 0.centos.pool.ntp.org iburst
systemctl restart ntpd
ntpq -p
vm.swappiness、kernel.hz 不影響時間精度。