Modify System and Hardware Time in Debian 12 在 Debian 12 上修改系統與硬體時間


Install systemd-timesyncd

sudo apt update -y && sudo apt upgrade -y
sudo apt install systemd-timesyncd -y

Set the Time Zone to Asia/Taipei

sudo timedatectl set-timezone Asia/Taipei

Enable and Start the Time Synchronization Service

systemctl enable systemd-timesyncd --now

Configure Multiple Taiwan NTP Servers

sudo nano /etc/systemd/timesyncd.conf
[Time]
NTP=tick.stdtime.gov.tw tock.stdtime.gov.tw time.stdtime.gov.tw watch.stdtime.gov.tw clock.stdtime.gov.tw
FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org

Enable NTP

sudo timedatectl set-ntp true

Restart the systemd-timesyncd Service

sudo systemctl restart systemd-timesyncd

Synchronize Hardware Clock

sudo hwclock --systohc

Display Hardware Clock

hwclock --show

安裝 systemd-timesyncd

sudo apt update -y && sudo apt upgrade -y
sudo apt install systemd-timesyncd -y

設定時區為 Asia/Taipei

sudo timedatectl set-timezone Asia/Taipei

啟用並啟動時間同步服務

systemctl enable systemd-timesyncd --now

設定多個台灣 NTP 伺服器

sudo nano /etc/systemd/timesyncd.conf
[Time]
NTP=tick.stdtime.gov.tw tock.stdtime.gov.tw time.stdtime.gov.tw watch.stdtime.gov.tw clock.stdtime.gov.tw
FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org

啟用 NTP

sudo timedatectl set-ntp true

重新啟動 systemd-timesyncd 服務

sudo systemctl restart systemd-timesyncd

同步硬體時鐘

sudo hwclock --systohc

顯示硬體時鐘

hwclock --show