nerdexam
CompTIA

LX0-104 · Question #447

The correct crontab entry to execute the script chklog once per hour between 3 p.m. and 5 p.m. on Monday and Thursday each week is, which of the following?

The correct answer is C. 0 15,16,17 * * 1,4 chklog. To schedule a cron job, the entry requires specific values for minute, hour, day of month, month, and day of week.

Administrative Tasks

Question

The correct crontab entry to execute the script chklog once per hour between 3 p.m. and 5 p.m. on Monday and Thursday each week is, which of the following?

Options

  • A0 3,4,5 * * 2,5 chklog
  • B0 3,4,5 * * 1,4 chklog
  • C0 15,16,17 * * 1,4 chklog
  • D0 15,16,17 1,4 * * chklog
  • E
    • 15,16,17 * * 1,4 chklog

How the community answered

(30 responses)
  • A
    7% (2)
  • B
    3% (1)
  • C
    80% (24)
  • E
    10% (3)

Why each option

To schedule a cron job, the entry requires specific values for minute, hour, day of month, month, and day of week.

A0 3,4,5 * * 2,5 chklog

This entry uses hours 3, 4, 5 (3 a.m. to 5 a.m.) instead of the required 3 p.m. to 5 p.m. and uses day of week 2 and 5 (Tuesday, Friday) instead of Monday and Thursday.

B0 3,4,5 * * 1,4 chklog

This entry uses hours 3, 4, 5 (3 a.m. to 5 a.m.) instead of the required 3 p.m. to 5 p.m.

C0 15,16,17 * * 1,4 chklogCorrect

The correct crontab entry `0 15,16,17 * * 1,4 chklog` executes the script `chklog` at the 0th minute (on the hour), during hours 15, 16, and 17 (3 p.m., 4 p.m., and 5 p.m. in 24-hour format), on any day of the month and any month, but specifically on day 1 (Monday) and day 4 (Thursday) of the week.

D0 15,16,17 1,4 * * chklog

This entry places `1,4` in the day of month field instead of the day of week field, which would cause it to run only on the 1st and 4th of the month, not on Monday and Thursday.

E* 15,16,17 * * 1,4 chklog

This entry uses `*` for the minute field, which would execute the script every minute between 3 p.m. and 5 p.m., rather than once per hour on the hour.

Concept tested: Crontab scheduling syntax and time specifications

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

Topics

#crontab#job scheduling#cron syntax#script execution

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice