• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Enable Debug Mode for Chronyd Service in CentOS/RHEL 8

by admin

What is Chronyd Service

In CentOS/RHEL 7 and 8, the operating system’s time is set on every boot based on the hardware clock, which is a small-battery driven clock located on the motherboard of your computer. Often, this clock is too inaccurate or has not been set right, therefore it’s better to get your system time from a reliable source over the Internet (that uses real atomic time). The chrony daemon, chronyd, sets and maintains system time through a process of synchronization with a remote server using the NTP protocol for communication.

In this post, we will learn to enable debug mode for chronyd service, which comes in very handy while troubleshooting any chronyd related issues. The configuration file used by chronyd service is /etc/sysconfig/chronyd.

1. Edit the configuration file /etc/sysconfig/chronyd as a root user:

# vi /etc/sysconfig/chronyd

2. Add or Modify below line.

OPTIONS="-dd"

3. Copy /lib/systemd/system/chronyd.service to /etc/systemd/system/:

# cp /lib/systemd/system/chronyd.service /etc/systemd/system/

4. Edit the file /etc/systemd/system/chronyd.service and change Type=forking to Type=simple:

# cat /etc/systemd/system/chronyd.service
[Unit]
Description=NTP client/server
Documentation=man:chronyd(8) man:chrony.conf(5)
After=ntpdate.service sntp.service ntpd.service
Conflicts=ntpd.service systemd-timesyncd.service
ConditionCapability=CAP_SYS_TIME

[Service]
Type=simple
PIDFile=/run/chrony/chronyd.pid
EnvironmentFile=-/etc/sysconfig/chronyd
ExecStart=/usr/sbin/chronyd $OPTIONS
ExecStartPost=/usr/libexec/chrony-helper update-daemon
PrivateTmp=yes
ProtectHome=yes
ProtectSystem=full

[Install]
WantedBy=multi-user.target

5. Restart chronyd service using systemctl:

# systemctl restart chronyd

6. Now the logs of chronyd will be much more verbose when checked for the status of chronyd and also /var/log/messages or journalctl command output would show more verbose logs.

Before:

Jun 03 18:21:47 geeklab.localdomain systemd[1]: Starting NTP client/server...
Jun 03 18:21:47 geeklab.localdomain systemd[1]: chronyd.service: Can't open PID file /run/chrony/chronyd.pid (yet?) after start-post: No such file or directory
Jun 03 18:21:47 geeklab.localdomain chronyd[14780]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Jun 03 18:21:47 geeklab.localdomain chronyd[14780]: Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift
Jun 03 18:21:47 geeklab.localdomain chronyd[14780]: Using right/UTC timezone to obtain leap second data
Jun 03 18:21:47 geeklab.localdomain systemd[1]: Started NTP client/server.

After:

Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_io_linux.c:811:(NIO_Linux_ProcessMessage) Received 110 (48) bytes from error queue for 2402:>
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_core.c:2234:(update_tx_timestamp) Updated TX timestamp delay=0.000018729
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_core.c:1176:(transmit_timeout) Transmit timeout for [106.10.186.200:123]
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_io.c:906:(NIO_SendPacket) Sent 48 bytes to 106.10.186.200:123 from [UNSPEC] fd 13
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_io_linux.c:811:(NIO_Linux_ProcessMessage) Received 90 (48) bytes from error queue for 106.10>
Jun 03 18:22:47 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:47Z ntp_core.c:2234:(update_tx_timestamp) Updated TX timestamp delay=0.000033359
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_core.c:1176:(transmit_timeout) Transmit timeout for [2606:4700:f1::1:123]
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_io.c:906:(NIO_SendPacket) Sent 48 bytes to 2606:4700:f1::1:123 from [UNSPEC] fd 14
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_io_linux.c:811:(NIO_Linux_ProcessMessage) Received 110 (48) bytes from error queue for 2606:>
Jun 03 18:22:48 geeklab.localdomain chronyd[14996]: 2020-06-03T12:52:48Z ntp_core.c:2234:(update_tx_timestamp) Updated TX timestamp delay=0.000019594

Filed Under: CentOS/RHEL 8, Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : iptables troubleshooting guide
  2. How to use command redirection under Linux
  3. sysctl setting for high load and prevent DDoS
  4. runlim: command not found
  5. pamac Command Examples in Linux
  6. groupmod Command Examples in Linux
  7. groupadd Command Examples in Linux
  8. How to Install gnome-session-wayland software package in Ubuntu
  9. CentOS / RHEL 6 : How to disable IPv6
  10. usermod Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright