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…
Question
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)- A15% (7)
- B2% (1)
- C7% (3)
- D72% (33)
- E4% (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
3instead of0, 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
Community Discussion
No community discussion yet for this question.