During development of a long-running service, you create a custom systemd unit called myapp.service. You want systemd itself to act as a health check: if the daemon stops sending the keep-alive notification within ten seconds after it has reported that it is ready, systemd must declare the unit failed and automatically restart it. Which single directive added to the [Service] section fulfills this requirement?
The watchdog function in systemd is enabled with the WatchdogSec= directive. When this value is non-zero and the service is of Type=notify, the daemon must call sd_notify with "WATCHDOG=1" at intervals shorter than the time specified. If no heartbeat is received within the full interval (10 s in this case), systemd marks the unit failed and-provided Restart is set to an appropriate value-restarts it.
TimeoutStartSec= only limits how long systemd waits for the initial start-up notification, RuntimeMaxSec= terminates a service that simply runs too long, and RestartSec= sets the delay after a crash before the next start. None of those options continuously test liveness the way WatchdogSec= does.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the WatchdogSec= directive in systemd?
Open an interactive chat with Bash
What is the difference between TimeoutStartSec= and WatchdogSec= in systemd?
Open an interactive chat with Bash
How does systemd determine when to restart a service using WatchdogSec=?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Troubleshooting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access