nerdexam
CompTIA

LX0-103 · Question #165

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:

The correct answer is C. 0 15,16,17 * * 1,4 chklog. This question tests knowledge of crontab time field syntax, specifically 24-hour time notation and day-of-week numbering.

GNU and Unix Commands

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:

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

(40 responses)
  • A
    3% (1)
  • B
    13% (5)
  • C
    75% (30)
  • D
    3% (1)
  • E
    8% (3)

Why each option

This question tests knowledge of crontab time field syntax, specifically 24-hour time notation and day-of-week numbering.

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

Uses 3,4,5 for hours which represents 3 AM to 5 AM, not 3 PM to 5 PM, and uses day values 2,5 which correspond to Tuesday and Friday, not Monday and Thursday.

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

Uses 3,4,5 for hours which represents 3 AM to 5 AM rather than 3 PM to 5 PM in 24-hour notation, even though the day-of-week values 1,4 are correct.

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

The crontab format is: minute hour day-of-month month day-of-week. Running once per hour at the top of the hour requires minute=0. 3 PM, 4 PM, and 5 PM in 24-hour format are 15, 16, and 17. Monday=1 and Thursday=4 in crontab day-of-week numbering (0=Sunday), so '0 15,16,17 * * 1,4 chklog' is the correct and complete entry.

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

Places the day values 1,4 in the day-of-month field (third field) instead of the day-of-week field (fifth field), so it would run on the 1st and 4th of every month rather than on Monday and Thursday.

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

Uses '*' for the minute field instead of '0', which would execute the script every minute during those hours rather than once per hour.

Concept tested: Linux crontab field syntax and 24-hour time notation

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

Topics

#crontab syntax#job scheduling#time specification#day of week

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice