Master Linux Time Sync with Chrony: Install, Configure, and Command Guide
This guide walks through installing Chrony on Linux, configuring its daemon and chrony.conf for both server and client roles, using chronyc commands to monitor synchronization, and managing time zones with timedatectl, providing all necessary commands and examples.
Installation and Configuration
Install chrony, enable and start the daemon, then edit /etc/chrony.conf with the default settings shown.
yum -y install chrony
systemctl enable chronyd
systemctl start chronyd
vim /etc/chrony.confDefault chrony.conf includes public pool servers, driftfile, makestep, rtcsync, and other common options.
# Use public servers from the pool.ntp.org project.
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
#hwtimestamp *
#minsources 2
#allow 192.168.0.0/16
#local stratum 10
#keyfile /etc/chrony.keys
logdir /var/log/chrony
#log measurements statistics trackingUsage
Server configuration
Modify chrony.conf to use internal NTP servers and allow the local network.
# Use public servers from the pool.ntp.org project.
server s1a.time.edu.cn iburst
server ntp.aliyun.com iburst
allow 192.168.8.0/24Enable synchronization:
systemctl enable chronyd
systemctl restart chronyd
timedatectl status
timedatectl set-ntp trueClient configuration
Set the client to use a local NTP server and allow its address.
# Use public servers from the pool.ntp.org project.
server 192.168.8.5 iburst
allow 192.168.8.5Enable synchronization (same commands as server).
systemctl enable chronyd
systemctl restart chronyd
timedatectl status
timedatectl set-ntp trueCommands
Common chronyc commands for monitoring:
# Show NTP sources
chronyc sources -v
# Show source statistics
chronyc sourcestats -v
# Show activity
chronyc activity -v
# Show tracking information
chronyc tracking -vTimezone management with timedatectl:
timedatectl
timedatectl list-timezones
timedatectl set-timezone Asia/Shanghai
timedatectl set-time "2019-09-19 15:50:20"
timedatectl set-ntp trueSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
