8 September 2023

Use ntpdate on CentOS 8 and RHEL 8 or derivatives

Time Synchronization on CentOS 8 and RHEL 8 and later: Deprecation of ntpdate at the Chronyd Implementation, a Detailed Guide on Installation, Configuration and Usage.

chrony-1-2

Introduction

Time synchronization is a crucial aspect of any computer system. An out-of-sync system clock can cause a variety of problems, ranging from erroneous logs to application and service failures. In the past, ntpdate was a popular tool used to synchronize the system clock with a Network Time Protocol (NTP) server. However, since the release of RHEL 8 and derivatives, Red Hat has eliminated it ntpdate and replaced it with Chronyd. In this post, we will explore what it is ntpdate, as Chronyd replaced it and how to use Chronyd on CentOS 8 and RHEL 8 or derivatives including AlmaLinux, Rocky Linux and similar.

What is ntpdate?

ntpdateis a software utility that is part of the Network Time Protocol (NTP) suite of protocols and tools. This command is specifically designed to synchronize a computer's system clock with a remote NTP server. The main goal of ntpdate is to provide a quick and relatively simple mechanism for bringing the system clock into alignment with a reliable time reference. This is especially useful in scenarios where “one-time” time synchronization is needed, such as during system startup or in environments where the machine is not running 24/7.

The functionality of ntpdate it is focused on immediate time synchronization operations and is not designed to provide real-time or continuous time synchronization. In other words, once the command is run ntpdate, the system clock is synchronized only once and there are no built-in mechanisms to maintain this synchronization over time. This is one reason why ntpdate it is often used in combination with ntpd (Network Time Protocol Daemon) or other NTP daemons.

Ntpd, Unlike ntpdate, is a daemon that performs time synchronization in the background, constantly monitoring multiple NTP servers and using sophisticated algorithms to determine the most accurate time. System administrators who need more robust and continuous time synchronization often opt to use ntpd or other similar services, reserving ntpdate for initial sync operations or for specific use cases where a one-time sync is sufficient.

Why Chronyd?

With the introduction of RHEL 8 and derivatives, ntpdate has been deprecated and replaced by Chronyd, a more modern and flexible daemon for time synchronization. Chronyd it was designed to work as both a client and a server, providing more accurate and reliable time synchronization than ntpdate. Furthermore, Chronyd it is best suited for systems that have intermittent Internet connections or frequently switch between different networks.

Installing Chronyd on CentOS 8 and RHEL 8

To install Chronyd on CentOS 8 or RHEL 8, follow the steps below:

  1. Open the terminal: Log in as root user or use sudo for subsequent commands.
  2. Update the system: Execute the command sudo dnf update to ensure you have all the latest updates.
  3. Install Chronyd: Execute the command sudo dnf install chrony.
  4. Enable and start the service: Use the following commands to enable and start the service chronyd.sudo systemctl enable chronyd
    sudo systemctl start chronyd
  5. Check the status: To make sure that Chronyd is running, run sudo systemctl status chronyd.

Chronyd Advanced Usage Syntax

Once you've completed installing Chronyd on your CentOS 8 or RHEL 8 system, you'll have a variety of commands and options to configure, manage, and monitor time synchronization. These commands are accessible through the command line interface chronyc, which is the command client for the daemon chronyd. Below, we delve into some of the most common and useful commands you can use to interact with Chronyd.

View Sync Status Information

The command chronyc tracking It is extremely useful for getting a detailed picture of the current state of time synchronization. This command provides information such as time offset, network delay, and the last NTP server the system was synchronized with. It's a great starting point for diagnosing problems or getting a general idea of ​​the effectiveness of your NTP setup.

List NTP Servers

To get a complete view of the NTP servers that your system is currently connected to or is trying to connect to, you can use the command chronyc sources. This command lists all configured NTP servers, also showing the status of each of them, which can be useful for identifying connectivity or latency problems.

Add an NTP Server

If you want to add a new NTP server to your configuration, you will need to edit the configuration file chrony.conf. This file is generally located in the directory /etc/chrony/. To add a new server, open the file with a text editor like vi o nano and add the following line:

server [server_name] iburst

Here, [nome_server] is the IP address or domain name of the NTP server you want to add. The option iburst is recommended because it attempts to quickly synchronize with the server by executing a sequence of queries in rapid succession.

Forcing an Instant Sync

In certain scenarios, such as after making significant changes to the server configuration or network, or in situations where it is critical that the system is accurately aligned to an NTP server, the need to force a time synchronization immediately may arise . In these cases, wait for the demon chronyd completing its background sync routine may not be a viable option.

To solve this problem and force immediate synchronization, the command chronyc makestep it is the ideal solution. When executed, this command routes chronyd to update the system clock as quickly as possible. This is done without taking into account drift settings (the variation of the system clock over time) or time correction limits that might normally affect how fast or how often chronyd updates the system clock.

It is important to note that the use of the command chronyc makestep it is a rather drastic action and should be used with caution. It is recommended to use it only when it is absolutely necessary to force an immediate synchronization and not as a common practice. This is because frequently forcing time synchronization could have implications for system stability and the accuracy of logging and other functions that depend on an accurate system clock.

Conclusion

Time synchronization is a vital element for the proper functioning of any system. Although ntpdate was a useful tool for time synchronization, its deprecation in favor of Chronyd on RHEL 8 and derivatives represents a significant step forward. Chronyd offers greater flexibility, accuracy and reliability, making it an excellent choice for time management on modern systems.

By following the installation and setup instructions provided in this post, you should be able to get set up Chronyd on CentOS 8 and RHEL 8 or derivatives with ease. With Chronyd, you not only ensure that your system is always synced with the exact time, but you also get more granular control over the syncing process.

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.

0256569681

Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.

INFORMATION

Managed Server Srl is a leading Italian player in providing advanced GNU/Linux system solutions oriented towards high performance. With a low-cost and predictable subscription model, we ensure that our customers have access to advanced technologies in hosting, dedicated servers and cloud services. In addition to this, we offer systems consultancy on Linux systems and specialized maintenance in DBMS, IT Security, Cloud and much more. We stand out for our expertise in hosting leading Open Source CMS such as WordPress, WooCommerce, Drupal, Prestashop, Joomla, OpenCart and Magento, supported by a high-level support and consultancy service suitable for Public Administration, SMEs and any size.

Red Hat, Inc. owns the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. owns the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds holds the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt. Oracle Corporation owns the rights to Oracle®, MySQL®, and MyRocks®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; REDIS® is a registered trademark of Redis Labs Ltd. F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB. Adobe Inc. holds the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited. Automattic Inc. owns the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert holds the rights to Drupal®. Amazon Web Services, Inc. holds the rights to AWS®; Google LLC holds the rights to Google Cloud™ and Chrome™; Microsoft Corporation holds the rights to Microsoft®, Azure®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®. Apache® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group. CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV Hetzner Online GmbH owns the rights to Hetzner®; OVHcloud is a registered trademark of OVH Groupe SAS; cPanel®, LLC owns the rights to cPanel®; Plesk® is a registered trademark of Plesk International GmbH; Facebook, Inc. owns the rights to Facebook®. This site is not affiliated, sponsored or otherwise associated with any of the entities mentioned above and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. Any other trademarks mentioned belong to their registrants. MANAGED SERVER® is a trademark registered at European level by MANAGED SERVER SRL, Via Enzo Ferrari, 9, 62012 Civitanova Marche (MC), Italy.

Back to top