date # 顯示系統時間
date "+%Y-%m-%d %H:%M:%S"
sudo date -s "2024-12-25 12:00:00" # 手動設定 (不建議,應用 NTP)
hwclock --show # 顯示 RTC 時間
hwclock --hctosys # RTC → 系統時鐘 (啟動時自動執行)
hwclock --systohc # 系統時鐘 → RTC (關機時自動執行)
hwclock --set --date="2024-12-25 12:00:00" # 直接設定 RTC
tzselect
# 依提示選擇:Asia → Taiwan → Taipei → 確認
輸出 TZ='Asia/Taipei',但不會自動寫入系統。
timedatectl # 顯示狀態
timedatectl list-timezones # 列出所有时区
timedatectl set-timezone Asia/Taipei
timedatectl set-time "2024-12-25 12:00:00"
timedatectl set-ntp true # 啟用 NTP 同步 (chrony/systemd-timesyncd)
cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
echo "Asia/Taipei" > /etc/timezone
vi /etc/sysconfig/clock
# ZONE="Asia/Taipei"
# UTC=false
# ARC=false
timeconfig # 文字介面設定
sudo apt install chrony
sudo vi /etc/chrony/chrony.conf
# 加入優質 NTP 伺服器
server time.stdtime.gov.tw iburst
server 1.tw.pool.ntp.org iburst
server 2.tw.pool.ntp.org iburst
sudo systemctl restart chrony
chronyc sources -v
chronyc tracking
sudo vi /etc/systemd/timesyncd.conf
[Time]
NTP=time.stdtime.gov.tw 1.tw.pool.ntp.org
FallbackNTP=time.google.com time.cloudflare.com
sudo systemctl restart systemd-timesyncd
timedatectl timesync-status
ntpdate time.stdtime.gov.tw
RealTimeIsUniversal=1)timedatectl set-local-rtc 0 # 設為 UTC 模式
timedatectl set-local-rtc 1 # 設為 Local 模式 (不建議)
# 檢查同步狀態
timedatectl status
chronyc tracking
# 手動強制同步
chronyc makestep
# 檢查時區資料庫版本
zdump -v Asia/Taipei | head -20
timedatectl 通常失效docker run -e TZ=Asia/Taipei -v /etc/localtime:/etc/localtime:ro ...