LX0-104 · Question #77
Which of the following crontab entries will execute myscript at 30 minutes past every hour on Sundays?
The correct answer is D. 30 0-23 * * 0 myscript. A crontab entry to execute a script at 30 minutes past every hour on Sundays requires setting the minute field to '30', the hour field to '0-23' (representing every hour), and the day-of-week field to '0' (for Sunday).
Question
Options
- A0 * * * 30 myscript
- B30 * * * 6 myscript
- C30 0 * * 0 myscript
- D30 0-23 * * 0 myscript
- E0 0-23 * * 30 myscript
How the community answered
(24 responses)- A17% (4)
- C8% (2)
- D71% (17)
- E4% (1)
Why each option
A crontab entry to execute a script at 30 minutes past every hour on Sundays requires setting the minute field to '30', the hour field to '0-23' (representing every hour), and the day-of-week field to '0' (for Sunday).
`0 * * * 30 myscript` would execute at 0 minutes past the hour on the 30th day of the week, which is invalid as days of the week are 0-7.
`30 * * * 6 myscript` would execute at 30 minutes past every hour on Saturdays, as '6' typically represents Saturday.
`30 0 * * 0 myscript` would execute at 00:30 (12:30 AM) only on Sundays, not every hour on Sundays.
The crontab format is `minute hour day-of-month month day-of-week command`. Here, `30` specifies 30 minutes past the hour, `0-23` specifies every hour, `*` for day-of-month and month, and `0` for Sunday (both 0 and 7 represent Sunday).
`0 0-23 * * 30 myscript` would execute at 0 minutes past every hour on the 30th day of the week, which is an invalid day-of-week specification.
Concept tested: Crontab syntax for scheduling
Source: https://man7.org/linux/man-pages/man5/crontab.5.html
Topics
Community Discussion
No community discussion yet for this question.