LFCS · Question #522
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. The crontab entry 0 15,16,17 1 chklog will execute the script chklog at 3 PM, 4 PM, and 5 PM on the first day of every month.
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
(27 responses)- A7% (2)
- B4% (1)
- D78% (21)
- E11% (3)
Why each option
The crontab entry `0 15,16,17 1 * * chklog` will execute the script `chklog` at 3 PM, 4 PM, and 5 PM on the first day of every month.
The minute field `*` would execute the script every minute, and the hour field `3,4,5` corresponds to 3 AM, 4 AM, and 5 AM, not PM.
The minute field `3` would execute the script at 3 minutes past the hour, and the hour field `3,4,5` corresponds to 3 AM, 4 AM, and 5 AM, not PM.
The minute field `3` would execute the script at 3 minutes past the hour, and the day-of-month field `*` would execute it every day, not just on a specific day of the month.
The minute field `0` ensures execution at the top of the hour, the hour field `15,16,17` specifies 3 PM, 4 PM, and 5 PM respectively, and the day-of-month field `1` ensures these executions occur on the first day of every month. This configuration correctly schedules the script to run three specific times during the specified period on a single day of the month.
The minute field `*` would execute the script every minute during the specified hours, not once at the top of each 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.