---
title: The Chronyd service is enabled
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > Datadog Security > OOTB Rules > The Chronyd service is enabled
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# The Chronyd service is enabled
 
## Description{% #description %}

chrony is a daemon which implements the Network Time Protocol (NTP) is designed to synchronize system clocks across a variety of systems and use a source that is highly accurate. More information on chrony can be found at [https://chrony-project.org/](https://chrony-project.org/). Chrony can be configured to be a client and/or a server. To enable Chronyd service, you can run: `# systemctl enable chronyd.service` This recommendation only applies if chrony is in use on the system.

## Rationale{% #rationale %}

If chrony is in use on the system proper configuration is vital to ensuring time synchronization is working properly.

## Remediation{% #remediation %}

### Shell script{% #shell-script %}

The following script can be run on the host to remediate the issue.

```bash
#!/bin/bash

# Remediation is applicable only in certain platforms
if dpkg-query --show --showformat='${db:Status-Status}' 'linux-base' 2>/dev/null | grep -q '^installed$' && { dpkg-query --show --showformat='${db:Status-Status}' 'chrony' 2>/dev/null | grep -q '^installed$'; }; then

var_timesync_service='systemd-timesyncd'


SYSTEMCTL_EXEC='/usr/bin/systemctl'

if [ $var_timesync_service == chronyd ]; then
  "$SYSTEMCTL_EXEC" unmask 'chrony.service'
  "$SYSTEMCTL_EXEC" start 'chrony.service'
  "$SYSTEMCTL_EXEC" enable 'chrony.service'
fi

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi
```

### Ansible playbook{% #ansible-playbook %}

The following playbook can be run with Ansible to remediate the issue.

```gdscript3
- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - service_chronyd_enabled
- name: XCCDF Value var_timesync_service # promote to variable
  set_fact:
    var_timesync_service: !!str systemd-timesyncd
  tags:
    - always

- name: Enable service chrony
  block:

  - name: Gather the package facts
    ansible.builtin.package_facts:
      manager: auto

  - name: Enable service chrony
    ansible.builtin.systemd:
      name: chrony
      enabled: 'yes'
      state: started
      masked: 'no'
    when:
    - '"chrony" in ansible_facts.packages'
    - var_timesync_service == "chronyd"
    - var_timesync_service == "chronyd"
  when:
  - '"linux-base" in ansible_facts.packages'
  - '"chrony" in ansible_facts.packages'
  tags:
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - service_chronyd_enabled
```
