Prevent Server Time Drift: Auto-Sync Linux Time with Chrony (NTP)

Did you know that servers suffer from "Time Drift"? Even the most expensive VPS can lag by several seconds or even minutes over a month of uptime. While a few seconds might seem harmless, in the world of servers, it is a disaster.

A drifting clock can cause SSL/TLS Handshake failures (your website becomes "Not Secure"), 2FA (Two-Factor Authentication) errors, and API rejections. If you recently migrated your server (maybe following my CentOS 7 to AlmaLinux 9 Guide), you might have forgotten to configure the Network Time Protocol (NTP).

Server clock drifting by minutes? Learn how to install and configure Chrony (NTP) on AlmaLinux/CentOS to keep your server time perfectly synced with Google Time

Install Chrony (The Modern NTP Client)

On modern Linux distributions like AlmaLinux, Rocky Linux, or Ubuntu 22.04, we use Chrony. It is faster and more accurate than the legacy ntp daemon, especially for servers with unstable network connections.

# Install the package
dnf install chrony -y

# Enable it to start on boot
systemctl enable chronyd

# Start the service immediately
systemctl start chronyd

Force Sync Now (Fixing Large Drifts)

If your time is already way off (e.g., 5 minutes behind), waiting for Chrony to adjust it slowly might take too long. You can force an immediate "step" update:

chronyc makestep

Verify Synchronization

How do you know it is working? Use this command to see the satellites/servers you are connected to:

chronyc sources

If you see a list of IPs with * or + symbols next to them, congratulations! Your server is now synchronized with atomic clock precision using the global NTP pool.

Conclusion

Never underestimate the importance of correct system time. Installing Chrony is a "set it and forget it" task that saves you from mysterious authentication bugs down the road. Make sure every server you deploy has this installed by default.


Author: Marg | Daily Innovate Tech

Post a Comment for "Prevent Server Time Drift: Auto-Sync Linux Time with Chrony (NTP)"