Keeping Time: Synchronizing a Linux System Clock with NTP Server

Ensuring Accuracy and Reliability in System Timekeeping

Accurate timekeeping is vital for the smooth operation of computing systems, particularly for servers where precise time is essential for various applications such as logging, authentication, and security. To achieve this, Linux systems utilize the Network Time Protocol (NTP), a widely adopted protocol for synchronizing computer clocks over a network.

In Linux environments, synchronizing the system clock with an NTP server can be effortlessly accomplished using the timedatectl command-line utility, which is integrated into the systemd system and service manager.

Step 1: Install Timesync Service

The systemd-timesyncd service, also known as Timesync, facilitates the synchronization of the local system clock with NTP servers. This minimalistic service is bundled with the systemd package and provides seamless time synchronization capabilities.

To install the service, execute the following command:

apt install systemd-timesyncd

Upon installation, the service will be automatically initiated. You can verify its status using:

sudo systemctl status systemd-timesyncd

Step 2: Enable Clock Synchronization

To enable clock synchronization with NTP servers, execute the following command:

sudo timedatectl set-ntp true

This command activates NTP synchronization and configures the system to automatically synchronize with NTP servers specified in the /etc/systemd/timesyncd.conf configuration file.

Step 3: Verify Changes

Confirm the status of NTP synchronization by running:

timedatectl

Step 4: Synchronize Hardware Clock

To synchronize the hardware clock with the system clock, execute:

sudo timedatectl set-local-rtc 1

In summary, leveraging the timedatectl set-ntp command facilitates seamless synchronization of the Linux system clock with an NTP server, ensuring precise timekeeping and minimizing potential issues arising from inaccurate time settings.

Share this article
0
Share
Shareable URL
Prev Post

’12th Fail’ actress Medha Shankr: Don’t think I am an overnight sensation

Next Post

Bus driver, conductor bite off UP passenger’s ear & finger

Read next
Whatsapp Join