Bird
0
0

What will be the output of this command if the cron log contains these lines:

medium📝 Command Output Q13 of 15
Linux CLI - Cron and Scheduling
What will be the output of this command if the cron log contains these lines:
Jun 10 10:00:01 server CRON[1234]: (root) CMD (backup.sh)
Jun 10 10:05:01 server CRON[1235]: (root) CMD (cleanup.sh)
Jun 10 10:10:01 server CRON[1236]: (root) CMD (backup.sh)

Command: grep backup.sh /var/log/cron
AJun 10 10:00:01 server CRON[1234]: (root) CMD (backup.sh) Jun 10 10:10:01 server CRON[1236]: (root) CMD (backup.sh)
BJun 10 10:05:01 server CRON[1235]: (root) CMD (cleanup.sh)
CNo output
DJun 10 10:00:01 server CRON[1234]: (root) CMD (backup.sh)
Step-by-Step Solution
Solution:
  1. Step 1: Understand grep filtering

    The grep backup.sh command filters lines containing 'backup.sh'.
  2. Step 2: Identify matching lines in the log

    Two lines contain 'backup.sh': the first and third lines.
  3. Final Answer:

    Both lines with backup.sh are shown -> Option A
  4. Quick Check:

    grep filters matching lines = C [OK]
Quick Trick: grep shows all lines containing the search term [OK]
Common Mistakes:
  • Selecting only one matching line
  • Expecting output for unrelated terms
  • Thinking grep outputs no lines if multiple matches exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes