# 系統時間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: no
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled-4/xi-tong-shi-jian-timedatectl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
