You have created a one-shot systemd unit named [email protected] that sends an email to on-call staff. The goal is for this notification unit to run automatically only when the main application unit orders-api.service enters the failed state (it must not trigger during a normal stop or restart). Which directive should you add to the orders-api.service unit file to accomplish this requirement?
Add FailureAction=notify-admin.service to the [Unit] section
Add StartLimitAction=notify-admin.service to the [Unit] section
Add OnFailure=notify-admin@%n.service to the [Unit] section
Add ExecStopPost=/usr/local/bin/notify-admin.sh to the [Service] section
The OnFailure= directive-placed in the [Unit] section-tells systemd to start one or more units whenever the referenced unit enters the failed state. Therefore, adding a line such as OnFailure=notify-admin@%n.service ensures the notification service is started only after a failure.
ExecStopPost= runs after any stop (clean or failure), so it is too broad. FailureAction= and StartLimitAction= accept values like reboot, reboot-force, or none; they cannot reference arbitrary service units and therefore cannot launch a custom notification service. RestartSec= controls the delay before an automatic restart and has nothing to do with launching notifications.
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 does the OnFailure= directive do in systemd?
Open an interactive chat with Bash
Why isn't ExecStopPost= suitable for failure-specific actions?
Open an interactive chat with Bash
What are FailureAction= and StartLimitAction= used for in systemd?
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