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

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

A. 0 * * * 30 myscript

B. 30 * * * 6 myscript

C. 30 0 * * 0 myscript

D. 30 0-23 * * 0 myscript

E. 0 0-23 * * 30 myscript

Answer: D

Explanation:

The correct crontab entry for executing myscript at 30 minutes past every hour on Sundays is D. 30 0-23 * * 0 myscript. This is because the crontab format consists of six fields: minute, hour, day of month, month, day of week, and command. The values for each field can be: A single number, such as 5 or 10.

A range of numbers, such as 1-5 or 10-15.

A list of numbers separated by commas, such as 1,3,5 or 10,12,14.

An asterisk (*), which means all possible values for that field.

A step value, which means every nth value for that field, such as */5 or 10-20/2.

The day of week field can be either a number from 0 to 6, where 0 and 7 are Sunday, or a three-letter abbreviation, such as SUN or MON. The month field can be either a number from 1 to 12, or a three-letter abbreviation, such as JAN or FEB.

In this case, the crontab entry

D. 30 0-23 * * 0 myscript means:

30: Execute the command at the 30th minute of every hour.

0-23: Execute the command for every hour from 0 (midnight) to 23 (11 PM).

*: Execute the command for every day of the month, regardless of the month.

*: Execute the command for every month, regardless of the year.

0: Execute the command only on Sundays.

The other options are either incorrect or do not match the requirement. For example, option

A. 0 * * * 30 myscript means:

0: Execute the command at the 0th minute of every hour. *: Execute the command for every hour of the day.

*: Execute the command for every day of the month, regardless of the month.

*: Execute the command for every month, regardless of the year.

30: Execute the command only on the 30th day of the week, which is invalid.

Reference: Crontab Explained in Linux [With Examples]

‘crontab’ in Linux with Examples – GeeksforGeeks

Crontab Syntax on Linux + Useful Examples – Hostinger

Latest 102-500 Dumps Valid Version with 194 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments