Courseiva
Troubleshooting →easyMultiple Choice

XK0-006 Troubleshooting Practice Question

A user reports that the 'backup.sh' script runs correctly when launched manually but silently does nothing when executed by cron at 02:00. The script relies on 'tar', which is found at /usr/bin/tar. Which action most directly resolves the failure?

⚠ Common exam trap

The trap here is blaming permissions or the shell, when the classic cron failure is a minimal environment missing PATH entries and profile variables.

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

✓

Set an explicit PATH variable inside the crontab or use absolute paths for commands in the script.

Cron jobs run in a minimal environment where PATH typically contains only /usr/bin:/bin, and shell startup files are not sourced. A script that works interactively can fail under cron because commands are resolved against a different PATH or depend on variables set in a profile. Defining PATH explicitly in the crontab, or referencing binaries by absolute path, restores the resolution the script needs. Capturing stderr to a log also helps reveal 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.

  • ✗

    Move the script into /etc/cron.daily so it inherits the system environment.

    Why it's wrong here

    Scripts in /etc/cron.daily still run with a stripped-down environment from run-parts, so a missing PATH entry would persist. Relocating the script also changes scheduling semantics and does not guarantee the tar binary is discoverable. The underlying cause is environment resolution, not the directory the script lives in.

  • ✓

    Set an explicit PATH variable inside the crontab or use absolute paths for commands in the script.

    Why this is correct

    Cron runs jobs with a minimal environment and a PATH that usually excludes /usr/local/bin and sometimes /usr/bin. When the script calls tar by name, the command is not found and the job fails silently unless output is captured. Defining PATH in the crontab or using absolute paths like /usr/bin/tar ensures the commands resolve, matching the manual-versus-cron discrepancy.

  • ✗

    Add 'SHELL=/bin/bash' to the crontab to force an interactive login shell.

    Why it's wrong here

    Setting SHELL selects the interpreter cron uses, but it does not make cron source login profiles or inherit an interactive PATH. Even under bash, cron starts a non-login, non-interactive shell that skips /etc/profile and ~/.bashrc. The missing command would still not be found, so this change does not resolve the failure.

  • ✗

    Change the script's permissions to 777 so cron can execute it.

    Why it's wrong here

    The script already runs correctly when invoked manually by the user, which proves the execute bits and read permissions are adequate. Cron executes with the privileges of the owning user, so loosening permissions to 777 does not address a missing command in the environment and introduces a security risk without fixing the root cause.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

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 →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

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.