LFCS · Question #768
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. The ntpdate command is used to synchronize the system clock with a remote NTP server, and it's commonly run from cron for periodic time synchronization.
Question
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
(36 responses)- A6% (2)
- B3% (1)
- C3% (1)
- D11% (4)
- E78% (28)
Why each option
The `ntpdate` command is used to synchronize the system clock with a remote NTP server, and it's commonly run from cron for periodic time synchronization.
The `date` command with the given arguments is used for displaying or setting the date manually, not for synchronizing with an NTP server; `$d`, `$t`, `$24` are not valid arguments for NTP synchronization.
`settime` is not a standard command for NTP synchronization, and the arguments are incorrect for any standard time synchronization.
Using `date` with input redirection `<ntp1.digex.net` is syntactically incorrect and not how time synchronization is performed.
`runcron` is not a standard utility for running cron jobs, and the subsequent `date <ntp1.digex.net` is still an incorrect method for NTP synchronization.
This crontab entry runs `/usr/sbin/ntpdate` at 00:01 daily, synchronizing the system clock with `ntp1.digex.net`. `ntpdate` is a standard command for one-time manual synchronization, and redirecting output to `/dev/null` suppresses command output, which is good practice for cron jobs.
Concept tested: Scheduling NTP time synchronization
Source: https://man7.org/linux/man-pages/man8/ntpdate.8.html
Topics
Community Discussion
No community discussion yet for this question.