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.
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
(58 responses)- A2% (1)
- B5% (3)
- C10% (6)
- D2% (1)
- E81% (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.
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.
`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.
The `date` command does not accept input redirection (`<`) from an NTP server's hostname to synchronize time; a proper NTP client utility is required.
`/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.
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
Community Discussion
No community discussion yet for this question.