LFCS · Question #447
The correct crontab entry to execute the script chklog once per hour between 3 p.m. and 5 p.m. on Monday and Thursday each week is, which of the following?
The correct answer is C. 0 15,16,17 * * 1,4 chklog. The correct crontab entry for this schedule specifies 0 for minutes, 15,16,17 for hours (3 PM to 5 PM in 24-hour format), for day and month, and 1,4 for Monday and Thursday.
Question
Options
- A0 3,4,5 * * 2,5 chklog
- B0 3,4,5 * * 1,4 chklog
- C0 15,16,17 * * 1,4 chklog
- D0 15,16,17 1,4 * * chklog
- E
- 15,16,17 * * 1,4 chklog
How the community answered
(23 responses)- B4% (1)
- C78% (18)
- D13% (3)
- E4% (1)
Why each option
The correct crontab entry for this schedule specifies `0` for minutes, `15,16,17` for hours (3 PM to 5 PM in 24-hour format), `* *` for day and month, and `1,4` for Monday and Thursday.
The hours `3,4,5` represent 3 AM, 4 AM, and 5 AM, not PM, and `2,5` represent Tuesday and Friday, not Monday and Thursday.
The hours `3,4,5` represent 3 AM, 4 AM, and 5 AM, not PM.
The crontab entry `0 15,16,17 * * 1,4 chklog` is correct because `0` specifies the minute (start of the hour), `15,16,17` specifies 3 PM, 4 PM, and 5 PM in 24-hour format, `* *` means every day and month, and `1,4` specifies Monday and Thursday (where Sunday is 0 or 7).
Placing `1,4` in the day of month field means the script would run on the 1st and 4th of each month, not specifically on Monday and Thursday of each week.
Using `*` in the minute field means the script would run every minute between 3 PM and 5 PM, not once per hour.
Concept tested: Crontab scheduling syntax
Source: https://man7.org/linux/man-pages/man5/crontab.5.html
Topics
Community Discussion
No community discussion yet for this question.