LFCS Service Configuration Practice Question
An administrator configures a systemd service with Restart=on-failure and RestartSec=10. What happens if the service exits with a non-zero exit code?
⚠ Common exam trap
Many candidates confuse Restart=on-failure with Restart=always, assuming any exit triggers a restart, or they forget that RestartSec applies even when Restart=on-failure is set, leading them to choose 'immediately' (Option A).
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
✓
It waits 10 seconds before restarting
When Restart=on-failure is set, systemd only restarts the service if it exits with a non-zero exit code or is terminated by a signal (excluding SIGHUP, SIGINT, SIGTERM, and SIGPIPE). The RestartSec=10 directive then introduces a 10-second delay before the restart attempt, preventing rapid restart loops and giving the system time to stabilize.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
It restarts immediately
Why it's wrong here
RestartSec=10 inserts a ten-second delay before systemd restarts the unit, so an immediate restart contradicts the configured timer. It is tempting because Restart=on-failure does trigger a restart, and that would be the behaviour if RestartSec were omitted or set to zero.
- ✗
It retries infinitely regardless of exit code
Why it's wrong here
Restart=on-failure restarts only on unclean exits, and systemd applies a start-limit burst that eventually stops further attempts, so infinite retries are wrong. It is tempting because the directive does loop restarts, which would be correct for a unit intended to run continuously despite crashes.
- ✗
It does not restart
Why it's wrong here
A non-zero exit code is precisely the failure condition Restart=on-failure acts on, so systemd does restart the unit after the ten-second delay. It is tempting because Restart=no is the default, and no restart would occur if the directive were absent or set to on-success.
- ✓
It waits 10 seconds before restarting
Why this is correct
Restart=on-failure triggers a restart whenever the process exits non-zero, and RestartSec=10 inserts a ten-second delay before systemd attempts that restart. This satisfies the stem's non-zero exit condition while honouring the configured interval, so the unit is relaunched after the pause rather than immediately.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LFCS question from scratch — 406 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.