nerdexam
CompTIA

LX0-104 · Question #278

Which of the following crontab entries could be used to set the system time at regular intervals?

The correct answer is E. 1 0 * * * /usr/sbin/ntpdate ntp1.digex.net > /dev/null 2>&1. The correct crontab entry utilizes the ntpdate command to synchronize the system time with an external NTP server, scheduled to run daily at 1 minute past midnight while suppressing all command output.

Essential System Services

Question

Which of the following crontab entries could be used to set the system time at regular intervals?

Options

  • A1 0 * * * date $d $t $24
  • B1 0 * * * settime $d $t $24
  • C1 0 * * * date<ntp1.digex.net
  • D1 0 * * * /usr/sbin/runcron date <ntp1.digex.net
  • E1 0 * * * /usr/sbin/ntpdate ntp1.digex.net > /dev/null 2>&1

How the community answered

(58 responses)
  • A
    2% (1)
  • B
    5% (3)
  • C
    10% (6)
  • D
    2% (1)
  • E
    81% (47)

Why each option

The correct crontab entry utilizes the `ntpdate` command to synchronize the system time with an external NTP server, scheduled to run daily at 1 minute past midnight while suppressing all command output.

A1 0 * * * date $d $t $24

The `date` command displays or sets the system date/time, but the arguments `$d $t $24` are not a valid or standard way to synchronize with an external time source.

B1 0 * * * settime $d $t $24

`settime` is not a standard Linux command for synchronizing time with an NTP server, and the arguments are invalid for setting time from a remote source.

C1 0 * * * date<ntp1.digex.net

The `date` command does not accept input redirection (`<`) from an NTP server's hostname to synchronize time; a proper NTP client utility is required.

D1 0 * * * /usr/sbin/runcron date <ntp1.digex.net

`/usr/sbin/runcron` is not a standard utility for running cron jobs or synchronizing time, and `date <ntp1.digex.net` is not a valid time synchronization method.

E1 0 * * * /usr/sbin/ntpdate ntp1.digex.net > /dev/null 2>&1Correct

The `ntpdate` command is a command-line utility specifically designed for one-time synchronization of the system clock with an NTP server, making it suitable for a scheduled cron job. The `> /dev/null 2>&1` redirection is a standard practice in cron entries to suppress command output and prevent unnecessary email notifications.

Concept tested: Cron job scheduling and NTP time synchronization

Source: https://man7.org/linux/man-pages/man8/ntpdate.8.html

Topics

#cron jobs#NTP synchronization#system time#ntpdate command

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice