Skip to main content

校時與時區設定

Chrony

Built-in on CentOS

Install

yum install chrony

Config: /etc/chrony.conf

# NTP Public Servers for Taiwan
server tw.pool.ntp.org
server time.stdtime.gov.tw
server clock.stdtime.gov.tw
server jp.pool.ntp.org

# Allow NTP client access from local network.
#allow 192.168.0.0/16

Starting

systemctl start chronyd

Verify

[root@localhost ~]# chronyc tracking
Reference ID    : 7A75FDF6 (static.home.twn.sciuridae.cloud)
Stratum         : 3
Ref time (UTC)  : Sun Aug 16 03:35:36 2020
System time     : 0.000073180 seconds slow of NTP time
Last offset     : -0.001259724 seconds
RMS offset      : 0.001259724 seconds
Frequency       : 21.057 ppm slow
Residual freq   : -0.000 ppm
Skew            : 28.166 ppm
Root delay      : 0.032856792 seconds
Root dispersion : 0.002069760 seconds
Update interval : 64.3 seconds
Leap status     : Normal

[root@tpemimtst99 ~]# timedatectl
               Local time: Tue 2021-05-25 09:09:09 CST
           Universal time: Tue 2021-05-25 01:09:09 UTC
                 RTC time: Tue 2021-05-25 01:09:09
                Time zone: Asia/Taipei (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

[root@tpemimtst99 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.21.86                 3  10   377   754  +1543ns[+4123ns] +/-   63ms

systemd-timesyncd

Build-in on Ubuntu

timedatectl

# See the information of the datetime
timedatectl

# List timezones supported
timedatectl list-timezones

# Change the system’s timezone
sudo timedatectl set-timezone Asia/Taipei
ntpd

Install

# Ubuntu
sudo apt install ntp

vi /etc/ntp.conf

#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst

# Use Ubuntu's ntp server as a fallback.
#pool ntp.ubuntu.com

# Added the local time server
server 192.168.21.86 prefer iburst

Restart the ntpd

# Ubuntu 16.04
systemctl stop ntp
systemctl start ntp

# Check the timeserver
ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 3.ubuntu.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
+eterna.binary.n 216.218.192.202  2 u   32   64    3   45.986   -0.081   0.021
+pacific.latt.ne 193.187.181.6    3 u   30   64    3    8.205    1.151   0.026
-mis.wci.com     216.218.192.202  2 u   32   64    3   37.928    4.692   0.176
-europa.ellipse. 209.180.247.49   2 u   31   64    3   51.792    4.175   0.027
#38.229.56.9     172.16.21.35     2 u   30   64    3   68.917   -4.451   0.190
#time.richiemcin 97.183.206.88    2 u   29   64    3   69.281   -3.073   0.248
*t1.time.gq1.yah 208.71.46.33     2 u   30   64    3   31.630   -0.081   0.011
-lofn.fancube.co 220.181.254.66   2 u   30   64    3   37.871   -1.088   0.009
#2606:6680:8:1:: 107.46.198.112   2 u   26   64    3  198.284   66.201   0.061
-titan.crash-ove 129.7.1.66       2 u   30   64    3   32.708   -1.474   0.200
-2620:1d5:100:43 47.187.174.51    2 u   29   64    3   70.418    0.592   0.197
 2001:67c:1560:8 17.253.34.123    2 u   32   64    3  133.490   -2.818   0.030
#38.229.57.9     172.16.21.35     2 u   30   64    3  177.896    4.081   6.291
#ntp2i.versadns. 217.180.209.214  2 u   28   64    3   62.795   -2.897   0.017
-104.194.8.227   192.12.19.20     2 u   25   64    3    0.979   -0.737   0.029
-pacific.latt.ne 193.187.181.6    3 u   26   64    3    8.770    1.212   0.050
 2001:67c:1560:8 17.253.34.123    2 u   33   64    3  133.602   -2.792   0.007