mediumMultiple Choice
XK0-006 Practice Question: A cron job runs a script that fails because the…
A cron job runs a script that fails because the command 'myapp' is not found. The script works when run manually by the same user. What is the most likely cause?
⚠ Common exam trap
Many exam-takers assume the script has a syntax error or that the cron daemon is failing, when the real issue is the stripped-down environment (especially PATH) that cron provides, which differs from the interactive shell environment.
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
✓
The PATH environment variable is different
When a cron job runs, it executes with a minimal environment, typically inheriting only a limited PATH (often just /usr/bin:/bin). The 'myapp' command is not found because its location (e.g., /usr/local/bin) is not in cron's PATH. When the same user runs the script manually, their interactive shell sources profile files (like .bash_profile or .bashrc) that set a more complete PATH, including the directory containing 'myapp'. This discrepancy is the most common cause of such failures.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The user does not have a home directory
Why it's wrong here
A missing home directory would not remove myapp from PATH, since cron uses a minimal PATH regardless; the command would still be found if installed in a standard directory. It tempts because home-directory issues do break some cron jobs, but not this 'command not found' symptom.
- ✗
The cron daemon is not running
Why it's wrong here
A stopped cron daemon means the job never runs at all, producing no output or error, rather than a 'command not found' failure. It tempts because daemon problems do stop scheduled jobs, but the stem shows the script executing and failing on PATH resolution.
- ✗
The script has syntax errors
Why it's wrong here
Syntax errors would fail identically when the user runs the script manually, yet the stem says manual execution succeeds. It tempts because syntax faults commonly break cron scripts, but the manual-success detail rules them out; the real cause is cron's minimal PATH.
- ✓
The PATH environment variable is different
Why this is correct
Cron executes with a minimal environment, so PATH typically omits the directory containing myapp. The interactive shell's profile adds that path, which is why manual runs succeed while the scheduled job cannot resolve the binary.
Go deeper
Related to this question
Learn chapter
Basic Shell Scripting
Key term
Shell
A shell is a computer program that provides a user interface to access an operating system's services, typically by accepting text commands.
Key term
cron
Cron is a time-based job scheduler in Unix-like operating systems that automatically runs commands or scripts at specified dates and times.
About these practice questions
Courseiva writes every XK0-006 question from scratch — 781 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 XK0-006 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-006 exam.