Skip to content

Instantly share code, notes, and snippets.

Last active May 21, 2019 19:02
Show Gist options
  • Save jdeathe/289af6ab1bc76e7a5cd097389d697989 to your computer and use it in GitHub Desktop.
Save jdeathe/289af6ab1bc76e7a5cd097389d697989 to your computer and use it in GitHub Desktop.
Keeping Time with Chrony on CentOS

CentOS - Keeping Time with Chrony

Both CentOS-6 and CentOS-7 provide chrony as an alternative to the traditional ntp service. Chrony is a good fit for virtualised guests - a Vagrant box using the VirtualBox provider where you don't have/want the VirtualBox Guest Additions installed on the guest.


First install the chrony package with yum.

# yum -y install chrony

Virtual Guest Configuration

For a Virtual Guest where the host can be powered off, hibernated or put into sleep mode (i.e a laptop) such that the virtual guest is suspended and resumed frequently it's necessary to configure chrony to allow it to make step changes at any time. Usually, you only want to make step changes during the initial few updates to correct large time drifts and then small corrections are made gradually to stop sudden changes in system time affecting running applications/services.

With the following command step changes can be made by chrony whenever the system time is off by more than 1 second.

# sed -r -i \
  -e 's~^(makestep )[0-9\.]+ (-)?[0-9]+$~\11 -1~' \

Set chronyd to Run on Startup


# chkconfig chronyd on


# systemctl enable chronyd

Start the chronyd Service


# service chronyd start


Note: If chronyd was running before making changes to the configuration, run the following to make the changes reflect in timedatectl.

# systemctl restart systemd-timedated

The chronyd service can be started by toggling the timedatectl set-ntp command.

# timedatectl set-ntp no \
  && timedatectl set-ntp yes



$ chronyc tracking


$ chronyc tracking


$ timedatectl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment