Courseiva
mediumMultiple ChoiceObjective-mapped

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 affect environment but not directly PATH.

  • The cron daemon is not running

    Why it's wrong here

    If the cron daemon were not running, no jobs would execute.

  • The script has syntax errors

    Why it's wrong here

    If the script worked manually, syntax is not the issue.

  • The PATH environment variable is different

    Why this is correct

    Cron uses a restricted PATH; the full path to 'myapp' should be specified in the crontab or script.

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 →

How Courseiva writes practice questions · Editorial policy

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.