Troubleshooting

An administrator wants a notification script to run automatically whenever backup.service enters a failed state. The notification is implemented as a separate systemd unit named notify-failure@.service. Which configuration accomplishes this?

Show the answer

Correct answerB. Add OnFailure=notify-failure@%n.service to the [Unit] section of backup.service

OnFailure= in the [Unit] section activates the listed unit when the service enters the failed state, and %n passes the failing unit's name. Restart=on-failure only restarts the service and sends no notification. OnSuccess= triggers on the opposite condition.