The answer is to add `RemainAfterExit=yes` to the `[Service]` section. This directive tells systemd to keep the service unit in an `active` state even after the main process—in this case, the backup script—has exited. Without it, systemd immediately marks the service as `inactive (dead)` the moment the process terminates, which is why the administrator sees the script run but the service status drop right away. On the CompTIA Linux+ XK0-005 exam, this concept tests your understanding of service lifecycle management and the distinction between a process finishing and a service remaining considered "active" for monitoring or dependency purposes. A common trap is confusing `RemainAfterExit` with `Type=oneshot`; remember that `oneshot` waits for the process to finish but still marks the service dead unless you pair it with `RemainAfterExit=yes`. For a memory tip, think of it as "Remain After Exit = Stay Alive After Goodbye"—the service stays up even after the main command says goodbye.
XK0-005 Scripting, Containers and Automation Practice Question
This XK0-005 practice question tests your understanding of scripting, containers and automation. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
Exhibit
Refer to the exhibit.
```
[Unit]
Description=Daily Backup Service
Requires=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
[Install]
WantedBy=multi-user.target
```
Refer to the exhibit. An administrator creates this systemd unit file for a backup script. When the administrator runs `systemctl start backup.service`, the script runs but the service shows 'inactive (dead)' immediately. What change should be made to keep the service active until the script finishes?
Clue words in this question
Noticing these words before you look at the options changes how you read each choice.
Clue: "immediately / without restart"
Why it matters: Time or reboot constraint — the correct answer must take effect right away without requiring a reboot or reload.
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Add 'RemainAfterExit=yes' to the [Service] section
The correct answer is A because adding 'RemainAfterExit=yes' to the [Service] section tells systemd to consider the service as active even after the main process (the backup script) exits. Without this directive, systemd sees the process terminate and immediately marks the service as 'inactive (dead)', even though the script may still be running or its effects are ongoing. This is the standard way to keep a service unit in an 'active' state after the main command completes.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
✓
Add 'RemainAfterExit=yes' to the [Service] section
Why this is correct
RemainAfterExit=yes keeps the service in 'active' state even after the process exits, which is what the administrator wants.
Clue confirmation
The clue word "immediately / without restart" in the question point toward this answer.
Related concept
Read the scenario before looking for a memorised answer.
✗
Change the service type to 'forking'
Why it's wrong here
Type=forking expects the process to fork and the parent to exit, which is not the case here.
✗
Add 'ExecStop' to the service definition
Why it's wrong here
ExecStop is for commands to run on stop, not for keeping the service active.
✗
Change the service type to 'simple'
Why it's wrong here
Type=simple would also show active only while the process runs, but after completion it becomes inactive, same issue.
Common exam traps
Common exam trap: answer the scenario, not the keyword
The trap here is that candidates often confuse 'RemainAfterExit' with service types like 'forking' or 'simple', mistakenly thinking changing the type will keep the service active, when in fact only 'RemainAfterExit' explicitly tells systemd to remain active after the process exits.
Trap categories for this question
Command / output trap
ExecStop is for commands to run on stop, not for keeping the service active.
Detailed technical explanation
How to think about this question
Under the hood, systemd tracks service state based on the lifecycle of the main PID. With 'RemainAfterExit=yes', systemd sets the unit state to 'active' after the main process exits and only transitions to 'inactive' when explicitly stopped via 'systemctl stop' or when 'ExecStop' is triggered. This is particularly useful for one-shot scripts or services that perform a task and then exit, but you want the service to be considered 'active' until manually stopped, such as for backup or maintenance scripts that should not be restarted automatically.
KKey Concepts to Remember
Read the scenario before looking for a memorised answer.
Find the constraint that changes the correct option.
Eliminate answers that are true in general but not in this case.
TExam Day Tips
→Watch for words such as best, first, most likely and least administrative effort.
→Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A small business has 20 workstations on the 192.168.1.0/24 network and one public IP from its ISP. The router uses PAT (NAT overload) so all 20 devices share one public address using different source ports. NAT questions test whether you understand the four address terms and which direction each translation applies.
Related glossary terms
Concepts from this question explained
These glossary pages explain the core terms tested in this XK0-005 question in full detail.
Scripting, Containers and Automation — This question tests Scripting, Containers and Automation — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: Add 'RemainAfterExit=yes' to the [Service] section — The correct answer is A because adding 'RemainAfterExit=yes' to the [Service] section tells systemd to consider the service as active even after the main process (the backup script) exits. Without this directive, systemd sees the process terminate and immediately marks the service as 'inactive (dead)', even though the script may still be running or its effects are ongoing. This is the standard way to keep a service unit in an 'active' state after the main command completes.
What should I do if I get this XK0-005 question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
Are there clue words in this question I should notice?
Yes — watch for: "immediately / without restart". Time or reboot constraint — the correct answer must take effect right away without requiring a reboot or reload.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
This XK0-005 practice question is part of Courseiva's free CompTIA 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 XK0-005 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.