LFCS · 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 for 30 minutes past every hour on Sundays requires setting the minute to 30, the hour to all (0-23 or *), and the day of week to 0 (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
(33 responses)- A9% (3)
- B3% (1)
- C12% (4)
- D73% (24)
- E3% (1)
Why each option
A crontab entry for 30 minutes past every hour on Sundays requires setting the minute to 30, the hour to all (0-23 or *), and the day of week to 0 (Sunday).
The last numeric field `30` represents the day of the week, where 0-7 are Sunday through Saturday, so `30` is an invalid day of the week.
The last field `6` represents Saturday, not Sunday, making it incorrect for 'Sundays'.
The second field `0` specifies only midnight (00:30), not every hour, making it incorrect for 'every hour on Sundays'.
The first field `30` specifies 30 minutes past the hour, `0-23` specifies every hour, `* *` specifies every day of the month and month, and `0` specifies Sunday as the day of the week, thus executing the script at 30 minutes past every hour on Sundays.
The first field `0` specifies 0 minutes past the hour, not 30 minutes past, and the last field `30` is an invalid day of the week.
Concept tested: Crontab syntax (day of week)
Source: https://man7.org/linux/man-pages/man5/crontab.5.html
Topics
Community Discussion
No community discussion yet for this question.