How to Sync Server Time in AlmaLinux: A Step-by-Step Guide

Categories:
Sync Server Time in AlmaLinux
Sync Server Time in AlmaLinux

How to Sync Server Time in AlmaLinux: A Step-by-Step Guide
Sync Server Time in AlmaLinux – Keeping your server’s time synchronized is crucial for maintaining the accuracy of logs, scheduling tasks, and ensuring that time-based applications function correctly. AlmaLinux, a popular RHEL fork, offers several methods for synchronizing time. In this blog post, we’ll walk you through the steps to sync server time using timedatectl, chrony, and ntpd.

Method 1: Using timedatectl for Quick Time Sync

timedatectl is a straightforward command-line utility that manages system time and date settings. If you need a quick sync without installing additional software, follow these steps:

  1. Check Current Time Configuration Open your terminal and run:
    timedatectl status

    This command displays the current time settings and whether NTP synchronization is enabled.

  2. Enable NTP Synchronization If NTP synchronization isn’t active, enable it with:
    sudo timedatectl set-ntp true

    This command will ensure your system synchronizes with NTP servers automatically.

  3. Verify Sync Status Confirm that NTP synchronization is enabled and check the status:
    timedatectl status

    Look for “NTP synchronized: yes” to ensure it’s working.

Method 2: Using chrony for Reliable Time Sync

chrony is the recommended time synchronization service for most modern Linux distributions, including AlmaLinux. It provides accurate timekeeping even on systems with intermittent internet connections.

  1. Install chrony Begin by installing chrony with:
    sudo dnf install chrony
  2. Start and Enable chronyd Service Activate and ensure chronyd starts on boot:
    sudo systemctl start chronyd
    sudo systemctl enable chronyd
  3. Force Immediate Time Sync To immediately synchronize the system clock, use:
    sudo chronyc makestep

    This forces chronyd to correct the system time without waiting for the next synchronization cycle.

  4. Check Synchronization Status Verify the synchronization status with:
    chronyc tracking

    This command provides detailed information about the current time synchronization.
    How to Change Time Zone in Linux

Method 3: Using ntpd for Time Sync

For those who prefer the older ntpd service, follow these steps:

  1. Install ntp Install the ntp package:
    sudo dnf install ntp
  2. Start and Enable ntpd Service Enable and start the ntpd service:
    sudo systemctl start ntpd
    sudo systemctl enable ntpd
  3. Sync Time Immediately Force an immediate synchronization with:
    sudo ntpdate -u pool.ntp.org

    Replace pool.ntp.org with your preferred NTP server if needed.

  4. Verify Synchronization Check the status of ntpd with:
    ntpq -p
    Sync Server Time in AlmaLinux
    Sync Server Time in AlmaLinux

    This command shows the list of NTP servers and their synchronization status.

Troubleshooting Tips

  • Firewall Settings: Ensure that your firewall allows NTP traffic (UDP port 123).
  • Network Connectivity: Verify that your server has internet access to reach NTP servers.
  • Manual Time Settings: Avoid manually setting the system time as it might interfere with synchronization.

Conclusion

Sync Server Time in AlmaLinux – Synchronizing server time is essential for system reliability and accuracy. AlmaLinux provides various tools to ensure your server’s clock stays accurate. Whether you prefer the simplicity of timedatectl, the robustness of chrony, or the traditional ntpd, you now have the steps to configure time synchronization effectively.