102-500 practice question 6 of 30

Which of the following crontab entries will execute myscript at 30 minutes past every hour on Sundays?

Full set: 233 questions
Answer options
A: 0 * * * 30 myscript
B: 30 * * * 6 myscript
C: 30 0 * * 0 myscript
D: 30 0-23 * * 0 myscript Correct answer
E: 0 0-23 * * 30 myscript
Correct Answer:
D. 30 0-23 * * 0 myscript
Explanation

The crontab format consists of five time-and-date fields followed by a command. The fields are: minute, hour, day of month, month, and day of week. To run a script at 30 minutes past every hour, the minute field must be 30 and the hour field must be (or its equivalent, 0-23). To run it only on Sundays, the day of week field must be 0 (or 7). Therefore, 30 0-23 0 myscript correctly specifies execution at 30 minutes past every hour (0 through 23) on every Sunday (0).

Why Incorrect

A. 0 30 myscript runs at the start of every hour on the 30th day of the month, which is incorrect.
B. 30 6 myscript runs at 30 minutes past every hour on Saturdays (6), not Sundays.
C. 30 0 0 myscript runs only once on Sunday, at 00:30 (30 minutes past midnight), not every hour.
E. 0 0-23 30 myscript runs at the start of every hour on the 30th day of the month.

References

1. Linux man-pages project. crontab(5) manual page. Section: "DESCRIPTION". It details the five time fields: "minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-7)".

2. Das, S. (2012). Your UNIX/Linux: The Ultimate Guide. McGraw-Hill. Chapter 11, Section: "Scheduling Jobs: cron and at", pp. 368-370. This section explains the crontab field layout and use of ranges.

3. University of Washington, CSE 391: Systems and Software Tools course materials. "Shell Scripting & Automation". The section on cron explains the syntax min hour dom mon dow command.

Scroll to Top