LFCS Service Configuration Practice Question
A system administrator is configuring a custom systemd service that runs a Python script. The script logs output to stdout. The administrator wants to ensure that the service restarts automatically if it crashes, but only after a 10-second delay. Which directive should be added to the [Service] section of the unit file?
⚠ Common exam trap
It's easy for candidates to confuse `Restart=on-failure` with `Restart=always`, not realizing that `always` restarts even on clean exits (e.g., `systemctl stop`), which would interfere with manual service management.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Restart=on-failure RestartSec=10
`Restart=on-failure` ensures the service restarts only when it exits with a non-zero exit code or is terminated by a signal (e.g., SIGKILL), which matches the 'crashes' scenario. Adding `RestartSec=10` introduces a 10-second delay before the restart attempt, as required. The other options either restart on success (irrelevant) or always restart (which would restart even on intentional stops), or omit the restart condition entirely.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Restart=on-success RestartSec=10
Why it's wrong here
Restarts on successful exit, not on failure.
- ✓
Restart=on-failure RestartSec=10
Why this is correct
Restarts the service only when it exits with a non-zero exit code or is terminated by a signal, with a 10-second delay.
- ✗
Restart=always RestartSec=10
Why it's wrong here
Restarts always, even on successful exit, which may not be desired.
- ✗
RestartSec=10
Why it's wrong here
Sets the delay but does not enable restarting on failure.
Go deeper
Related to this question
About these practice questions
This LFCS question is part of Courseiva's 507-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.