ntpdate
Synchronize system's date and time via NTP
TLDR
Synchronize and set date and time
Query the host without setting the time
Use an unprivileged port in case a firewall is blocking privileged ports
Force time to be stepped using settimeofday instead of slewed
SYNOPSIS
ntpdate [options] server [server...]
PARAMETERS
-4
Force IPv4 address resolution.
-6
Force IPv6 address resolution.
-b
Adjust the local clock to be synchronized using the adjtime()
system call, which can handle large time offsets more gracefully. However, it is often less accurate.
-d
Enable debug mode. Display extra output about the synchronization process.
-e authdelay
Specify the authentication delay, in seconds. This is used for authenticated NTP servers.
-o version
Specify the NTP protocol version number (1, 2, 3, or 4). The default is 4.
-p samples
Specify the number of samples to acquire from each server. Values are from 1 to 8 inclusive. Normally ntpdate
takes a few samples from each server. Higher numbers can be usefull in high unstable environments.
-q
Query mode. Only query the servers without setting the time. Useful for testing server availability.
-s
Silent mode. Suppress output.
-t timeout
Specify the timeout, in seconds, for contacting a server.
-u
Use an unprivileged port for outgoing packets. This is useful when behind a firewall that filters outgoing traffic.
server
The hostname or IP address of an NTP server to query.
DESCRIPTION
The ntpdate
command is an older utility used to set the system's date and time by querying a Network Time Protocol (NTP) server. It operates by contacting one or more NTP servers and retrieving the current time from them.
Important: It's considered obsolete and should be replaced by ntpd
or chronyd
for continuous time synchronization. ntpdate
only performs a one-time synchronization, which can lead to jumps in time if the system clock drifts significantly. This can negatively affect applications sensitive to time changes. Using a daemon such as ntpd
or chronyd
is preferable because they provide continuous time adjustment and avoid abrupt changes.
While still available on some systems, its use is discouraged. Modern systems primarily rely on daemons like timedatectl
or systemd-timesyncd
for time synchronization, which are more robust and prevent potential issues arising from sudden time adjustments.
CAVEATS
ntpdate
can cause abrupt time changes, which can disrupt applications and system logs. It's not suitable for environments requiring continuous and smooth timekeeping. Modern systems should use ntpd
, chronyd
or systemd-timesyncd
instead.
SECURITY CONSIDERATIONS
Using publicly available NTP servers can pose security risks. Ensure that you are using trusted NTP servers and consider authenticating to prevent man-in-the-middle attacks. However, modern NTP daemons offer more robust security features compared to the legacy ntpdate
.
ALTERNATIVES
timedatectl
is a popular systemd command that allows to control and synchronize the system clock. systemd-timesyncd
is a daemon process that takes care about small adjustments with ntp protocol.
HISTORY
ntpdate
was a common tool for one-time NTP synchronization. As system requirements evolved, the need for continuous, stable timekeeping led to the development and widespread adoption of NTP daemons like ntpd
and chronyd
. ntpdate
is now considered legacy, and its use is generally discouraged.
SEE ALSO
ntpd(8), chronyd(8), timedatectl(1), systemd-timesyncd(8)