校時與時區設定

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

[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# 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

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