Linux Exam LFCS: How to Schedule Cron Jobs on Sundays

Executing myscript at 30 minutes past every hour on Sundays

Question

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

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

D

The correct answer is B.

Explanation:

The crontab entry format is:

scss
* * * * * command-to-be-executed - - - - - | | | | | | | | | ----- Day of the week (0 - 7) (Sunday to Saturday; 0 or 7 both represent Sunday) | | | ------- Month (1 - 12) | | --------- Day of the month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)

To execute myscript at 30 minutes past every hour on Sundays, we need to set the minute field to 30 and the day of the week field to 6 (since 0 or 7 both represent Sunday).

Option A: 0 * * * 30 myscript This entry will execute myscript at the 0th minute of every hour on the 30th day of every month. This is not what we want.

Option B: 30 * * * 6 myscript This entry will execute myscript at the 30th minute of every hour on Sundays.

Option C: 30 0 * * 0 myscript This entry will execute myscript at the 30th minute of the 0th hour (midnight) on Sundays.

Option D: 30 0-23 * * 0 myscript This entry will execute myscript at the 30th minute of every hour on every day of the week, including Sunday. This is not what we want.

Option E: 0 0-23 * * 30 myscript This entry will execute myscript at the 0th minute of every hour on the 30th day of every month. This is not what we want.

Therefore, the correct answer is B.