Skip to content

Commit

Permalink
ntpd: switch service type from forking to simple
Browse files Browse the repository at this point in the history
Type=forking means systemd waits untill the main process, /usr/sbin/ntpd
in this case, has exited. However, the ntpd daemon does not seem to call
fork() or vfork() and runs endlessly untill killed. Eventually, this
causes systemd to trigger a timeout, and the ntpd service is killed. All
the while, "systemctl status ntpd" shows "activating (start)" instead of
"active (running)". This is fixed by switching Type=forking to
Type=simple.

Reading ntpd(8) shows that the "-n" option requests ntpd not to fork, so
also use that to be safe.

Finally, there is no need anymore to keep a pidfile around.

Signed-off-by: Johannes Kauffmann <johanneskauffmann@hotmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
  • Loading branch information
JohannesKauffmann authored and kraj committed Jun 15, 2023
1 parent 45a8bb2 commit d04c39d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions meta-networking/recipes-support/ntp/ntp/ntpd.service
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ Description=Network Time Service
After=network.target

[Service]
Type=forking
PIDFile=/run/ntpd.pid
ExecStart=/usr/sbin/ntpd -u ntp:ntp -p /run/ntpd.pid -g
Type=simple
ExecStart=/usr/sbin/ntpd -u ntp:ntp -n -g

[Install]
WantedBy=multi-user.target

0 comments on commit d04c39d

Please sign in to comment.