LFCS · 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. A crontab entry using ntpdate is the appropriate method to set the system time from an NTP server at regular intervals.
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
(50 responses)- A2% (1)
- B2% (1)
- C4% (2)
- D8% (4)
- E84% (42)
Why each option
A crontab entry using `ntpdate` is the appropriate method to set the system time from an NTP server at regular intervals.
The `date` command alone is for displaying or manually setting the time and does not inherently synchronize with an external time source like an NTP server.
`settime` is not a standard command-line utility used for synchronizing system time from an NTP server.
The syntax `date<ntp1.digex.net` is incorrect for synchronizing time; the `date` command does not accept an NTP server hostname via standard input.
`/usr/sbin/runcron` is not a standard utility for time synchronization, and the command `date <ntp1.digex.net` is still syntactically incorrect for synchronizing with an NTP server.
The `ntpdate` command synchronizes the system's clock with a specified NTP server, making it suitable for a cron job that needs to regularly update the system time. The redirection `> /dev/null 2>&1` suppresses all command output, which is standard practice for cron entries.
Concept tested: Cron job for time synchronization
Source: https://man7.org/linux/man-pages/man8/ntpdate.8.html
Topics
Community Discussion
No community discussion yet for this question.