nerdexam
CompTIA

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).

Administrative Tasks

Question

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

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)
  • A
    17% (4)
  • C
    8% (2)
  • D
    71% (17)
  • E
    4% (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).

A0 * * * 30 myscript

`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.

B30 * * * 6 myscript

`30 * * * 6 myscript` would execute at 30 minutes past every hour on Saturdays, as '6' typically represents Saturday.

C30 0 * * 0 myscript

`30 0 * * 0 myscript` would execute at 00:30 (12:30 AM) only on Sundays, not every hour on Sundays.

D30 0-23 * * 0 myscriptCorrect

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).

E0 0-23 * * 30 myscript

`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

#crontab syntax#scheduled tasks#cron scheduling

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice