Skip to main content
Maintaining an accurate system clock is essential for many server operations. Hardware clocks can drift over time, causing discrepancies that might affect scheduling, logging, and security operations. In this guide, you’ll learn how to synchronize time on Linux systems using network peers and the Chrony daemon. Chrony is the default time synchronization tool in modern CentOS systems. It regularly updates the system clock by retrieving time data from trusted internet servers. For example, even a small drift—where your server shows 6 seconds past midnight while the actual time is 5 seconds—can result in noticeable inaccuracies over prolonged periods.

Verify Chrony Service

To confirm that Chrony is running correctly, execute the following command:
Ensure that the Chrony service is active, enabled, and free from errors. If the service appears inactive or displays errors, refer to the troubleshooting steps in the official Chrony documentation.

Checking System Time Settings

You can inspect the current system time configuration with the timedatectl command:
An unsynchronized clock can lead to issues in log management and automated tasks. Always verify that the system time is accurate.

Configuring Time Zone

Before setting up Chrony, it’s important to configure the correct time zone for your server. For instance, to set your server’s time zone to New York time, use:
To view a list of all available time zones, run:

Installing and Enabling Chrony

If Chrony is not already installed on your system, follow these steps:
  1. Install Chrony using the package manager:
  2. Start the Chrony service:
  3. Enable Chrony to start automatically at boot:

Verifying Time Synchronization

After installing Chrony, check again using timedatectl:
If you find that the system clock is still not synchronized, force synchronization by running:
For additional details on troubleshooting time synchronization issues, please refer to the Chrony Troubleshooting Guide.

Conclusion

By following the aforementioned steps, your server will maintain the correct time automatically, enhancing the reliability of server processes. Accurate timekeeping is crucial for server security, logging, and overall performance. Now, let’s get started with some hands-on labs.

Watch Video

Practice Lab