Showing posts with label chrony. Show all posts
Showing posts with label chrony. Show all posts

Tuesday, August 15, 2023

Enable server time sync in ubuntu with chrony

Chrony is an implementation of the Network Time Protocol (NTP). It is an alternative to ntpd, a reference implementation of NTP. It runs on Unix-like operating systems (including Linux and macOS) and is released under the GNU GPL v2. It is the default NTP client and server in Red Hat Enterprise Linux 8 and SUSE Linux Enterprise Server 15, and available in many Linux distributions.


To enable chrony in ubuntu, we can install it first
$ sudo apt update && sudo apt install chrony -y
Start chrony once it is installed
$ sudo systemctl start chrony
Enable chrony on boot
$ sudo systemctl enable chrony
We can change the server that chrony sync from, by editing /etc/chrony/chrony.conf. By default, chrony in ubuntu will use ntp.ubuntu.com







To check the status of time sync
$ sudo chronyc sources -v

We can see that from the above example, the current best source of time is 144.126.242.176.

Make sure there is at least one server with ^* status.

If the time is skewed, we can force resync using below command 
$ sudo chronyc makestep
To install and configure chrony in redhat based linux, please refer to this article

Friday, May 31, 2019

Update time and date using chrony

Chrony is an application for a machine to sync with network time protocol servers.

To install chrony
# yum install chrony -y

Then, make sure to include some legit ntp servers in /etc/chrony.conf. In this case, we are using centos ntp pool servers.
# cat /etc/chrony.conf
...
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

...

Start chronyd (chrony daemon)
# systemctl start chronyd

Chrony will gradually update the system clock to follow the ntp servers, once chronyd is started. But if you want to chrony to update the time quickly, just use below command
# chronyc makestep

To start chronyd on boot:
# systemctl enable chronyd

To check if the time has been synced (make sure one of the server has ^* on the left hand side)
# chronyc sources -v
...
^* time.cloudflare.com           0   6     0     -     +0ns[   +0ns] +/-    0ns
...