---
tags: asrlab
---
# Chrony 校時
## NTP service for Time synchronization
The Unex’s device with protocol provide NTP service through chronyd. If you want to subscribe this service, you can install chrony on your host and modify configuration file. The details are as follows:
### Install chrony on host
```
$ sudo apt-get install chrony
```
### Add one line below in `/etc/chrony/chrony.conf`
```
server {HOST_IP} iburst
```
並且將原本在 `/etc/chrony/chrony.conf` 中的這四行註解掉,否則會連到除了 `{HOST_IP}` 以外的 IP 來校時
```
pool ntp.ubuntu.com iburst maxsources 4
pool 0.ubuntu.pool.ntp.org iburst maxsources 1
pool 1.ubuntu.pool.ntp.org iburst maxsources 1
pool 2.ubuntu.pool.ntp.org iburst maxsources 2
```
### Restart chrony service
重新啟動服務 <!--- 前電腦要連接網路且 DSRC 要接上 GPS 且確保 GPS 有收到訊號-->
```
$ sudo systemctl restart chrony.service
```
Need to wait few second after restart the service. Then the system time should be synchronized.
The following commands can help you check the status of NTP service
### Run the chronyc tracking command to check chrony tracking.
```
$ chronyc tracking
Reference ID : C0A80103 (192.168.1.3)
Stratum : 2
Ref time (UTC) : Fri Aug 07 03:22:15 2020
System time : 0.000002473 seconds fast of NTP time
Last offset : +0.000011065 seconds
RMS offset : 0.000092991 seconds
Frequency : 505.203 ppm fast
Residual freq : +0.003 ppm
Skew : 0.303 ppm
Root delay : 0.001189028 seconds
Root dispersion : 0.000195598 seconds
Update interval : 64.4 seconds
Leap status : Normal
Run the chronyc sources command to display information about the current time sources that chronyd is accessing.
```
```
$ chronyc sources -v
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.1.3 1 6 377 4 +37us[ +68us] +/- 619us
```
### Server allow 連線
https://ailog.tw/lifelog/2021/07/09/chrony/