nerdexam
CompTIA

LX0-103 · Question #168

Which crontab entry 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. This question tests knowledge of the correct Linux command and syntax for synchronizing the system clock with a remote NTP server via crontab.

GNU and Unix Commands

Question

Which crontab entry 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

(25 responses)
  • A
    8% (2)
  • C
    4% (1)
  • D
    12% (3)
  • E
    76% (19)

Why each option

This question tests knowledge of the correct Linux command and syntax for synchronizing the system clock with a remote NTP server via crontab.

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

The date command is used to display or manually set the system time using locally provided values, not to contact a remote NTP server, and $d $t $24 are not valid date command arguments.

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

settime is not a standard Linux command and does not exist as a recognized utility for NTP-based time synchronization on typical Linux distributions.

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

Using '<' to redirect the NTP server hostname as stdin input to the date command performs no network communication - the date command does not read NTP server addresses from stdin.

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

/usr/sbin/runcron is not a valid or standard Linux command, and attempting to redirect the NTP hostname via stdin to date still does not perform any network time synchronization.

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

The ntpdate command is the standard utility for querying an NTP server and immediately setting the system clock to match. The syntax '/usr/sbin/ntpdate ntp1.digex.net' correctly passes the NTP server hostname as a positional argument. Redirecting all output to /dev/null 2>&1 suppresses cron email noise, and '1 0 * * *' schedules it to run at 12:01 AM every day.

Concept tested: NTP time synchronization using ntpdate command in crontab

Source: https://linux.die.net/man/8/ntpdate

Topics

#crontab#ntpdate#NTP#time synchronization

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice