Red Hat Certified System Administrator(RHCSA)

Manage Basic Networking

Configure time service clients

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:

$ systemctl status chronyd.service
Selected source 185.82.232.254 (2.centos.pool.ntp.org)
System clock was stepped by -0.000844 seconds

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:

$ timedatectl
Local time: Mon 2021-12-20 01:02:20 CST
Universal time: Mon 2021-12-20 07:02:20 UTC
RTC time: Mon 2021-12-20 07:02:20
Time zone: America/Chicago (CST, -0600)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no

Note

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:

$ sudo timedatectl set-timezone America/New_York

To view a list of all available time zones, run:

$ timedatectl list-timezones
America/Adak
America/Anchorage
America/Anguilla
America/Antigua
America/Araguaina
America/Argentina/Buenos_Aires
America/Argentina/Catamarca
America/Argentina/Cordoba

Installing and Enabling Chrony

If Chrony is not already installed on your system, follow these steps:

  1. Install Chrony using the package manager:

    $ sudo dnf install chrony
    
  2. Start the Chrony service:

    $ sudo systemctl start chronyd.service
    
  3. Enable Chrony to start automatically at boot:

    $ sudo systemctl enable chronyd.service
    Created symlink /etc/systemd/system/multi-user.target.wants/chronyd.service → /usr/lib/systemd/system/chronyd.service.
    

Verifying Time Synchronization

After installing Chrony, check again using timedatectl:

$ timedatectl
Local time: Mon 2021-12-20 01:22:49 CST
Universal time: Mon 2021-12-20 07:22:49 UTC
RTC time: Mon 2021-12-20 07:22:46
Time zone: America/Chicago (CST, -0600)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

If you find that the system clock is still not synchronized, force synchronization by running:

$ sudo systemctl set-ntp true

Note

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

Watch video content

Practice Lab

Practice lab

Previous
Statically route IP traffic