mediumMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A cron job runs a script that uses a command only…
A cron job runs a script that uses a command only available in a custom directory. The script fails from cron but works in the user's shell. Which of the following is the most common cause?
⚠ Common exam trap
CompTIA often tests the misconception that cron inherits the user's interactive shell environment, leading candidates to incorrectly choose option C (user mismatch) instead of recognizing that cron does not source shell initialization files.
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 cron job does not source the user's .bashrc
The most common cause is that cron jobs run in a minimal environment and do not source the user's shell initialization files like .bashrc. This means the custom directory containing the command is not in the PATH variable when the script executes under cron, even though it works in the user's interactive shell where .bashrc is sourced.
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 script is not executable
Why it's wrong here
If not executable, the script would also fail when run manually as ./script.sh.
- ✗
The script has incorrect line endings
Why it's wrong here
Would cause issues in both environments if present.
- ✗
The cron job runs as root but command is in user's PATH
Why it's wrong here
Root's PATH typically includes standard directories; custom user PATH would not apply.
- ✓
The cron job does not source the user's .bashrc
Why this is correct
Cron's minimal environment lacks the custom PATH defined in .bashrc.
Go deeper
Related to this question
Learn chapter
User and Group Administration
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.
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.
About these practice questions
Courseiva writes every XK0-006 question from scratch — 979 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.