


How to configure chrony to synchronize system time with an NTP server?
Jul 29, 2025 am 01:19 AMChrony is a lightweight and efficient time synchronization tool in Linux. The configuration steps are as follows: 1. Modify the /etc/chrony.conf file, add the server to point to the NTP server and use the iburst parameter to accelerate synchronization; 2. Restart the chrony service after saving, pay attention to the service name chronyd or chrony; 3. Verify the synchronization status through chronyc sources -v and chronyc tracking; 4. Ensure that the firewall opens UDP 123 port and can use makestep to manually synchronize time. Common public NTP servers include pool.ntp.org and time.google.com. It is recommended to set up multiple sources for redundancy when configuring.
Chrony is a very practical time synchronization tool in Linux systems. It is lighter and more efficient than traditional NTPD, and is especially suitable for dynamic network environments. If you need to keep your system time synchronized with an NTP server, configuring chrony is a good choice.
Modify configuration file: Specify NTP server
The main configuration file of Chrony is generally located in /etc/chrony.conf
. You need to add or modify server
line in this file to point to the NTP server you want to synchronize.
For example:
server ntp.example.com iburst
- The
iburst
parameter indicates that the fast synchronization mode is used (4 packets are sent continuously) during the initial synchronization phase to speed up the connection. - You can write a few more lines of server instructions to point to multiple different NTP servers for redundancy.
Common public NTP services include:
-
pool.ntp.org
-
time.google.com
- NTP addresses provided by major universities or organizations
Remember to save the configuration file and restart the chrony service.
Start and enable the chrony service
After the configuration is complete, make sure that the chrony service has been started and set to power on and start.
You can use the following command:
- Start the service:
sudo systemctl start chronyd
- Set up startup:
sudo systemctl enable chronyd
- View status:
sudo systemctl status chronyd
Note: Some systems may have a service name of
chrony
instead ofchronyd
, and they can be automatically completed through tab or check the service list to confirm.
If the service is running normally, chrony will automatically synchronize according to the NTP server you configured.
Verify the time synchronization status
You can check the current synchronization through the chronyc
command:
chronyc sources -v
This lists all configuration sources and their status. Focus on:
-
^*
indicates the server currently in use -
reach
field is an octal number. If it is 0, it means that the server cannot be connected. -
offset
displays the deviation between local time and server time (usually milliseconds)
Can also be executed:
chronyc tracking
Check the last synchronization time and current accuracy and other information.
Other precautions
If your server is behind a firewall, make sure UDP 123 port is open because NTP uses this port.
Chrony automatically synchronizes every 64 seconds to 24 hours by default, and the specific frequency is dynamically adjusted by the algorithm.
If you want to trigger a synchronization manually, you can use:
sudo chronyc makestep
However, note that
makestep
will directly jump to the time, which may affect some applications. It is recommended to use it only when the system starts.
Basically that's it. Configuring chrony is not complicated, but it is easy to ignore the permissions and service status issues. When encountering problems, you can start from logs (such as
/var/log/messages
orjournalctl
).The above is the detailed content of How to configure chrony to synchronize system time with an NTP server?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In Linux system, using the usermod command to add users to the secondary group is: 1. Execute the sudousermod-a-G group name username command to add, where -a means append to avoid overwriting the original secondary group; 2. Use groups username or grep group name /etc/group to verify whether the operation is successful; 3. Note that the modification only takes effect after the user logs in again, and the main group modification should use the -g parameter; 4. You can also manually edit the /etc/group file to add users, but be careful to avoid system abnormalities caused by format errors.

To migrate from CentOS8 to AlmaLinux or RockyLinux, follow the clear steps. First, choose AlmaLinux (suitable for long-term enterprise support) or RockyLinux (emphasizing exactly the same as RHEL) according to your needs. Secondly, prepare the system environment: update the software package, back up key data, check third-party repositories and disk space. Then, the conversion is automatically completed using the official migration script. RockyLinux needs to clone the repository and run the switch-to-rocky.sh script. AlmaLinux replaces the repository and upgrades with one click through the remote deployment script. Finally, verify system information, clean up residual packets, and update GRUB and ini if ??necessary

To correctly install the local RPM file and handle dependencies, you should first use dnf to install it directly, because it can automatically obtain the required dependencies from the configured repository; if the system does not support dnf, you can use yum's localinstall command instead; if the dependency cannot be resolved, you can manually download and install all related packages; finally, you can also forcefully ignore the dependency installation, but this method is not recommended. 1. Use sudodnfinstall./package-name.rpm to automatically resolve dependencies; 2. If there is no dnf, you can use sudoyumlocalinstall./package-name.rpm; 3. Force installation and execute sudorpm-ivh--nod

How to set a static IP address using nmcli on CentOS8 or 9? 1. First run the nmcliconnectionshow and ipa commands to view the current network interface and its configuration; 2. Use the nmcliconnectionmodify command to modify the connection configuration, specify parameters such as ipv4.methodmanual, ipv4.addresses (such as 192.168.1.100/24), ipv4.gateway (such as 192.168.1.1), and ipv4.dns (such as 8.8.8.8). 3. Run the nmcliconnectiondown and up commands to restart the connection to make the changes take effect, or

The current running mode of SELinux can be viewed through the command line. Use getenforce command to directly display the current status, and the output is Enforcing, Permissive or Disabled; view the /etc/selinux/config file to know the default startup mode; temporarily change the mode can be setenforce1 (enforcing) or setenforce0 (permissive), but restore the configuration file settings after restart; in actual applications, you need to pay attention to service compatibility issues, and switch modes to troubleshoot problems if necessary.

Installing and configuring fail2ban on CentOS is not complicated, it mainly includes the following steps: 1. Install fail2ban using yum; 2. Manually enable and start the service; 3. Create a jail.local file for custom configuration; 4. Set SSH defense rules, including enabling sshd, specifying the blocking time and retry times; 5. Configure firewalld as an action actuator; 6. Regularly check the blocking IP and logs. Fail2ban detects abnormal login behavior through monitoring logs and automatically blocks suspicious IPs. Its core mechanism relies on key parameters such as bantime (banned time), findtime (statistic window time) and maxretry (maximum failure number).

AminimalinstallofCentOSisalightweightsetupthatincludesonlyessentialcomponents,makingitidealforserversorsystemsrequiringfullcontrol.Itcontainscoreutilitieslikebash,yum/dnf,networkingtools,andsecuritypackages,whileexcludingdesktopenvironments,webserver

KernelCare and kpatch are both tools for implementing hot patches in the Linux kernel, but the applicable scenarios are different. 1. KernelCare is a commercial service that supports CentOS, RHEL, Ubuntu and Debian, automatically applies patches without restarting, and is suitable for hosting service providers and enterprise production environments; 2. kpatch is an open source tool developed by Red Hat. It is based on the ftrace framework and requires manual construction of patch modules. It is suitable for RHEL and compatible systems, and is suitable for organizations that need to finely control the patch process or use customized kernels. When choosing, automation requirements, system distribution, whether official support is required, and the degree of control over open source tools should be considered. Neither of them can fix all vulnerabilities, some still need to be restarted, and
