Configuring Network Time Protocol (NTP) on Linux using timedatectl
Introduction –
Accurate time synchronization is crucial for the proper functioning of systems and applications. Network Time Protocol (NTP) is a widely used protocol that allows systems to synchronize their clocks over a network. In this article, we will explore how to configure NTP on Linux (Red Hat Enterprise Linux) using the timedatectl
command. We’ll cover topics such as listing available time zones, setting the time zone, verifying the time zone, manually setting the time, and configuring automatic time synchronization with an NTP server.
Listing Available Time Zones
To get a list of all available time zones, you can use the following command with grep
to filter for specific regions such as America or Canada:
1
timedatectl list-timezones | grep -E '(America|Canada)'
This command will display a list of time zones that match the specified region criteria, making it easier to find the desired time zone for your system.
Setting the Time Zone
To set the time zone on Linux, utilize the timedatectl
command with the set-timezone
option, followed by the desired time zone. For example, to set the time zone to “America/New_York,” execute the following command:
1
sudo timedatectl set-timezone America/New_York
Replace “America/New_York” with the appropriate time zone identifier from the list obtained in the previous step.
Verifying the Time Zone
To verify the currently configured time zone, you can use the timedatectl
command with the show
option. Execute the following command:
1
timedatectl show --property=Timezone --value
This command will display the currently set time zone on your Linux system.
Manually Setting the Time
If you need to manually set the system time on Linux, you can use the timedatectl
command with the set-time
option, followed by the desired time in the format “YYYY-MM-DD HH:MM:SS.” For example, to set the system time to “2023-06-25 14:30:00,” execute the following command:
1
sudo timedatectl set-time '2023-06-25 14:30:00'
Make sure to adjust the date and time values according to your requirements.
Configuring Automatic Time Synchronization with an NTP Server
To configure automatic time synchronization with an NTP (Network Time Protocol) server on Linux, you can use the timedatectl
command with the set-ntp
option. Enabling this feature allows your system to automatically synchronize its time with the specified NTP server. Execute the following command to enable automatic time synchronization:
1
sudo timedatectl set-ntp true
Once enabled, your system will regularly synchronize its time with the NTP server, ensuring accurate timekeeping.
Please note that you may need to configure the appropriate NTP server addresses in your system’s network configuration for successful synchronization.
In conclusion, configuring Network Time Protocol (NTP) on Linux is essential for accurate time synchronization. The timedatectl
command provides a straightforward way to manage time-related settings, including setting the time zone, manually adjusting the system time, and configuring automatic time synchronization with an NTP server. By following the steps outlined in this article, you can ensure accurate timekeeping on your Linux system, improving system reliability and synchronization across your network.
Featured Tweet
Discover how to configure Network Time Protocol (NTP) using timedatectl on RHEL / CentOS.#NTP #timedatectl #LinuxAdmin #CentOSStream9 #TechBloghttps://t.co/ckhp26zvtT
— rcdevops (@rcdevops) February 4, 2024