ntpdate command is used to set the date and time in a Linux system using the Network Time Protocol (NTP). NTP is a protocol used to synchronize the clock of a computer system to a reference time source, such as a time server on the internet or a local network. The
ntpdate command is typically used to synchronize the clock of a Linux system with a remote NTP server.
The syntax of the
ntpdate command is as follows:
ntpdate [options] server
server is the hostname or IP address of the NTP server to synchronize with.
For example, to synchronize the clock of a Linux system with the NTP server at
time.google.com, you would use the following command:
sudo ntpdate time.google.com
This will set the date and time on the system to the current time as reported by the NTP server.
Specific use cases
- Synchronizing the clock of a Linux system with an NTP server on the internet or a local network.
- Ensuring that the clock of a Linux system is accurate for time-sensitive applications, such as logging or database transactions.
sudo ntpdate time.google.com: Synchronize the clock of the system with the NTP server at
sudo ntpdate -u pool.ntp.org: Synchronize the clock of the system with a random NTP server from the
The following options are available for the
||Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call.|
||Increase the debug level, producing more output about the NTP server response.|
||Query the NTP server, but do not set the time.|
||Use an unprivileged port to query the NTP server.|
- If the system clock is not being set correctly, ensure that the NTP server is reachable and responding to requests. Use the
-doption to increase the debug level and check the output for errors or warnings.
- If the system clock is being set to the wrong time, ensure that the correct timezone is set on the system. Use the
timedatectlcommand to view or set the timezone.
ntpdatecommand has been deprecated in favor of the
ntpddaemon, which provides continuous clock synchronization rather than one-time synchronization.