系統時間timedatectl
NTP 是通過網路來同步時間的一種 TCP/IP 協議。通常客戶端向伺服器請求當前的時間,並根據結果來設定其時鐘。
timedatectl
在最新的 Ubuntu 版本中,timedatectl 替代了老舊的 ntpdate。預設情況下,timedatectl 在系統啟動的時候會立刻同步時間,並在稍後網路連線啟用後通過 socket 再次檢查一次。
安裝 ntpdate / ntp,timedatectl 會讓你使用之前的設定。確保兩個時間同步服務不會相互衝突,升級時還保留原本的配置。
timesyncd
在最新的 Ubuntu 版本中,timesyncd 替代了 ntpd 的客戶端的部分。預設情況下 timesyncd 會定期檢測並同步時間。它還會在本地儲存更新的時間,以便在系統重啟時做時間單步調整。
通過 timedatectl 和 timesyncd 設定的當前時間狀態和時間配置,可以使用 timedatectl status 命令來進行確認。
timedatectl status
Local time: 日 2020-01-12 10:03:11 CST
Universal time: 日 2020-01-12 02:03:11 UTC
RTC time: 日 2020-01-12 02:03:11
Time zone: Asia/Taipei (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: noLast updated
Was this helpful?