nerdexam
LPI

102-500 · Question #138

The correct crontab entry to execute the script chklog three times per month between 3 p.m. and 5 p.m.:

The correct answer is D. 0 15,16,17 1 * * chklog. Option D is correct because crontab fields follow the order minute hour day-of-month month day-of-week command, and 0 15,16,17 1 chklog fires exactly once at the top of each hour (minute 0) during hours 15, 16, and 17 (3 p.m., 4 p.m., 5 p.m.) on the 1st of every month - that's…

Administrative Tasks

Question

The correct crontab entry to execute the script chklog three times per month between 3 p.m. and 5 p.m.:

Options

  • A
    • 3,4,5 1 * * chklog
  • B3 3,4,5 1 * * chklog
  • C3 15,16,17 * * * chklog
  • D0 15,16,17 1 * * chklog
  • E
    • 15,16,17 1 * * chklog

How the community answered

(46 responses)
  • A
    15% (7)
  • B
    2% (1)
  • C
    7% (3)
  • D
    72% (33)
  • E
    4% (2)

Explanation

Option D is correct because crontab fields follow the order minute hour day-of-month month day-of-week command, and 0 15,16,17 1 * * chklog fires exactly once at the top of each hour (minute 0) during hours 15, 16, and 17 (3 p.m., 4 p.m., 5 p.m.) on the 1st of every month - that's exactly 3 executions per month within the required window.

Why the others fail:

  • A & B use hours 3,4,5, which is 3–5 a.m., not p.m.; forget 12-hour clock thinking - cron uses 24-hour time.
  • B additionally uses minute 3 instead of 0, which is a minor issue but the AM error is the dealbreaker.
  • C omits the day-of-month restriction (* means every day), so the script would run 3 times daily - roughly 90+ times a month, not 3.
  • E uses minute *, meaning it fires every minute across all three hours on day 1 - that's 180 executions, not 3.

Memory tip: Think of cron as M H D M D (My Hamster Doesn't Mind Dancing) - Minute, Hour, Day-of-month, Month, Day-of-week. For PM times, always add 12 (3 p.m. = 15, 5 p.m. = 17), and a lone * in the minute field means "every minute," which usually signals a wrong answer when a specific frequency is required.

Topics

#crontab#job scheduling#24-hour time format#system automation

Community Discussion

No community discussion yet for this question.

Full 102-500 Practice