Question 89 of 510
Scripting, Containers and AutomationeasyMultiple ChoiceObjective-mapped

Quick Answer

The answer is to change the script to log output to a file. This is correct because when a cron job runs but produces no output, it often indicates a silent failure—the script executes but errors are not captured, leaving no trace in the logs. By redirecting both stdout and stderr to a log file using syntax like `>> /var/log/cleanup.log 2>&1`, you capture all output and error messages, making it possible to diagnose why the script occasionally fails. On the CompTIA Linux+ XK0-005 exam, this scenario tests your understanding of cron job troubleshooting and the importance of logging for debugging background tasks. A common trap is assuming the job didn’t run at all, when in fact it ran but failed silently due to missing environment variables or permissions. Remember the mnemonic “Cron + Log = Clarity” to always redirect output when troubleshooting cron job no output issues.

XK0-005 Scripting, Containers and Automation Practice Question

This XK0-005 practice question tests your understanding of scripting, containers and automation. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. 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

$ crontab -l
0 2 * * * /usr/local/bin/cleanup.sh

Refer to the exhibit. A system administrator notices that the cleanup script runs at 2:00 AM every day but sometimes does not execute. The log shows no output from the script. Which step should be taken to investigate?

Question 1easymultiple choice
Full question →

Exhibit

$ crontab -l
0 2 * * * /usr/local/bin/cleanup.sh

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

Change the script to log output to a file.

Option D is correct because the script runs but produces no log output, indicating it may be failing silently. Redirecting the script's stdout and stderr to a file (e.g., `>> /var/log/cleanup.log 2>&1`) captures error messages and output, allowing the administrator to see why the script sometimes does not execute or fails. This is the most direct way to diagnose a cron job that runs but yields no visible results.

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.

  • Verify that the script is executable by the root user.

    Why it's wrong here

    This is a basic check but does not explain intermittent failures or lack of output.

  • Check the syslog for cron execution messages.

    Why it's wrong here

    Syslog shows cron job starts but not script output or errors.

  • Add a MAILTO directive to the crontab.

    Why it's wrong here

    MAILTO sends email with output, but only if output is generated; still not captured if script silently fails.

  • Change the script to log output to a file.

    Why this is correct

    Redirecting stdout and stderr to a file allows administrators to see error messages and diagnose failures.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates assume 'no output' means the script didn't run, leading them to check cron execution (Option B) or permissions (Option A), when the real issue is that the script runs but fails silently, requiring output redirection to diagnose the failure.

Trap categories for this question

  • Command / output trap

    This is a basic check but does not explain intermittent failures or lack of output.

Detailed technical explanation

How to think about this question

Cron jobs inherit a minimal environment (PATH=/usr/bin:/bin) and no terminal, so scripts that rely on interactive features or specific environment variables may fail silently. Redirecting output to a file with absolute paths ensures that any error messages (e.g., 'command not found', permission denied) are captured, and using `2>&1` merges stderr into stdout for a complete log. In real-world scenarios, a script might fail due to a missing dependency or a changed working directory, and without explicit logging, the administrator sees only an empty log.

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 practitioner preparing for the XK0-005 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related XK0-005 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free XK0-005 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this XK0-005 question test?

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: Change the script to log output to a file. — Option D is correct because the script runs but produces no log output, indicating it may be failing silently. Redirecting the script's stdout and stderr to a file (e.g., `>> /var/log/cleanup.log 2>&1`) captures error messages and output, allowing the administrator to see why the script sometimes does not execute or fails. This is the most direct way to diagnose a cron job that runs but yields no visible results.

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.

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 →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 25, 2026

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.

Loading comments…

Sign in to join the discussion.

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.