Sunday, August 11, 2024

Network Time Protocol (NTP)

In Linux, Network Time Protocol (NTP) is the protocol used to synchronize the system clock with a remote server. 

NTP(Network time Protocol):

Validate if NTP is active by running below command, which provide output of current time, UTC time etc.

$ timedatectl

Example output:
$ timedatectl
Local time: Sat 2024-08-10 13:32:19 CDT
Universal time: Sat 2024-08-10 18:32:19 UTC
RTC time: Sat 2024-08-10 18:32:19
Time zone: America/Chicago (CDT, -0500)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

If NTP is not activie, enable as below
$ sudo timedatectl set-ntp true
$ view /var/log/syslog | grep ntp

Install NTP client: An NTP client is a software component that synchronizes a computer’s clock with a reference time source, typically an NTP server. The client periodically requests the current time from the server and adjusts its local clock accordingly.
$ sudo apt install ntpdate
$ sudo apt install ntp

Verify: $ ntpstat, $ntpq -p

Sync time with Chrony:

Install as below
$ sudo apt install chrony
or
$ sudo yum install chrony
Verify By:
$ sudo service chronyd status
In RHEL7: vi /etc/chrony.conf
In RHEL6: VI /etc/ntp.conf

Some use full chronyc commands

1) For tracking
$ chronyc tracking

2) To know sync sources
$ chronyc sources
$ chronyc sources -v

3) To know stats
$ chronyc sourcestat

Summary:
NTP, chrony, openntpd are implementations of the Network Time Protocol (NTP). 

Chrony is more modern with improved timestamping, authentication and encrypting. It has smaller code size and lightweight than NTP and is default in RHEL variants.
NTP is traditional implementation and has larger code size and more resource intensive.
Openntpd is another implementation.

***

No comments:

Post a Comment