nerdexam
CompTIA

XK0-005 · Question #125

A Linux administrator needs to schedule a cron job to run at 1:15 p.m. every Friday to report the amount of free disk space on the system and to send the output to a file named "freespace". Which of…

The correct answer is B. 15 13 * * 5 df > /freespace. The cron job entry 15 13 5 df > /freespace correctly schedules the df command to run at 1:15 p.m. (13:15 in 24-hour format) every Friday (day of week 5) and redirects its output to /freespace.

System Management

Question

A Linux administrator needs to schedule a cron job to run at 1:15 p.m. every Friday to report the amount of free disk space on the system and to send the output to a file named "freespace". Which of the following would meet this requirement?

Options

  • A13 15 * * 5 df > /freespace
  • B15 13 * * 5 df > /freespace
  • C15 1 * * 6 df > /freespace
  • D15 13 6 * * df > /freespace

How the community answered

(32 responses)
  • A
    6% (2)
  • B
    88% (28)
  • C
    3% (1)
  • D
    3% (1)

Why each option

The cron job entry `15 13 * * 5 df > /freespace` correctly schedules the `df` command to run at 1:15 p.m. (13:15 in 24-hour format) every Friday (day of week 5) and redirects its output to `/freespace`.

A13 15 * * 5 df > /freespace

The minute and hour fields are swapped; `13 15` would mean 3:13 p.m. instead of 1:15 p.m.

B15 13 * * 5 df > /freespaceCorrect

The cron syntax follows `minute hour day_of_month month day_of_week command`. Here, `15` is the minute, `13` is 1 p.m. (24-hour format), `*` for day of month and month means every day/month, and `5` represents Friday (where 0 or 7 is Sunday). `df > /freespace` executes the disk free command and redirects its output to the specified file.

C15 1 * * 6 df > /freespace

`15 1 * * 6` would run at 1:15 a.m. on Saturday, not 1:15 p.m. on Friday.

D15 13 6 * * df > /freespace

`15 13 6 * *` would run at 1:15 p.m. on the 6th day of every month, not specifically every Friday.

Concept tested: Cron job scheduling syntax

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

Topics

#cron jobs#task scheduling#df command#I/O redirection

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice