4.7 Keeping Time in Sync: Utilizing time_date_ctl for Network Time Synchronization

I'm Vijay Kumar Singh, a Linux, DevOps, Cloud enthusiast learner and contributor in shell scripting, Python, networking, Kubernetes, Terraform, Ansible, Jenkins, and cloud (Azure, GCP, AWS) and basics of IT world. 💻✨ Constantly exploring innovative IT technologies, sharing insights, and learning from the incredible Hashnode community. 🌟 On a mission to build robust solutions and make a positive impact in the tech world. 🚀 Let's connect and grow together!
#PowerToCloud
Introduction:
Ensuring accurate timekeeping is crucial for various operations in a computer system, from logging events to coordinating tasks across multiple devices. One method to synchronize time across a network is by utilizing Network Time Protocol (NTP) servers. In this guide, we'll explore how to synchronize time using other network peers in Linux using the timedatectl command, particularly focusing on the chronyd implementation of NTP.
Understanding Chrony and NTP: Chrony is an implementation of the NTP protocol, designed to synchronize system clocks accurately with reference clocks or NTP servers. It offers flexibility in synchronization methods, including synchronization with NTP servers, reference clocks (e.g., GPS receivers), manual time inputs, and acting as an NTP server or peer.
Using Chrony withtimedatectl: To synchronize time using other network peers with chronyd, we can leverage the timedatectl command along with chronyc for monitoring and management. Here's how to utilize these tools effectively:
Checking Chrony Status:
systemctl status chronydUse this command to check the status of the
chronyddaemon, ensuring it's running and operational.Tracking Chrony Synchronization:
chronyc trackingThis command provides detailed information about the system's synchronization status with NTP sources, including the offset, delay, and synchronization status.
Viewing Chrony Sources:
chronyc sourcesUse this command to view information about the NTP sources configured in Chrony, including their status and reachability.
Setting Timezone with
timedatectl:sudo timedatectl set-timezone America/New_YorkIf
chronydis not installed, usetimedatectlto set the timezone. ReplaceAmerica/New_Yorkwith the desired timezone.Enabling NTP Synchronization:
sudo systemctl set-ntp trueThis command enables NTP synchronization, allowing the system clock to synchronize with NTP servers automatically.
#To check the status of chronyd use the following command:
systemctl status chronyd
#To Check Chrony Synchronization
chronyc tracking
#To check information about chrony’s sources:
chronyc sources
#Setting timezone if chronyd is not installed
#Ex set to Newyork
sudo timedatectl set-timezone America/New_York
#View all timezones available
timedatectl list-timezones
#If system clock is not in sync with NTP servers run
sudo systemctl set-ntp true
Conclusion:
Synchronizing time using other network peers is essential for maintaining accurate timekeeping in Linux systems, especially in networked environments where coordination is critical. By leveraging tools like chronyd and timedatectl, administrators can ensure that system clocks remain synchronized with reliable NTP sources, minimizing discrepancies and improving system reliability. Understanding how to check synchronization status, configure timezones, and enable NTP synchronization is essential for effective time management in Linux environments.






