nerdexam
CompTIA

XK0-004 · Question #432

A new web server was recenly installed and configured according to vendor.......... management via SSH has shown slow screen responses. The systems administrator.. An administrator is setting up a scr

The correct answer is D. 15 3 * * * script,sh. Crontab fields are ordered minute, hour, day-of-month, month, day-of-week, so 3:15 AM daily is expressed as '15 3 *'.

Scripting, Containers and Automation

Question

A new web server was recenly installed and configured according to vendor.......... management via SSH has shown slow screen responses. The systems administrator.. An administrator is setting up a script named script,sh to be executed daily at 3:15 a.m. Which of the following is the correct way to define this in crontab?

Options

  • A
        • 15 3 script,sh
  • B3 15 * * * script,sh
  • C
        • 3 15 script,sh
  • D15 3 * * * script,sh

How the community answered

(22 responses)
  • B
    9% (2)
  • C
    5% (1)
  • D
    86% (19)

Why each option

Crontab fields are ordered minute, hour, day-of-month, month, day-of-week, so 3:15 AM daily is expressed as '15 3 * * *'.

A* * * 15 3 script,sh

Placing values in the fourth and fifth fields targets month and day-of-week positions, not minute and hour, making this expression syntactically invalid for the intended time.

B3 15 * * * script,sh

This swaps minute and hour, which would schedule the task at 15:03 (3:03 PM) rather than 03:15 AM.

C* * * 3 15 script,sh

The values appear in the month and day-of-week fields rather than the minute and hour fields, so no execution would occur at 3:15 AM.

D15 3 * * * script,shCorrect

The crontab format is: minute(0-59) hour(0-23) day-of-month(1-31) month(1-12) day-of-week(0-7) command. Scheduling at 3:15 AM requires minute=15 and hour=3, with wildcards for the remaining three fields, producing '15 3 * * * script.sh'. Answer D matches this exactly.

Concept tested: Crontab scheduling syntax and field ordering

Source: https://man7.org/linux/man-pages/man5/crontab.5.html

Topics

#crontab#cron syntax#scheduled tasks#daily jobs

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice