← 返回命令列表

Linux command

ntpdate 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Synchronize and set

sudo ntpdate [host]

Query

ntpdate -q [host]

Example

sudo ntpdate -u [host]

Force time to be stepped

sudo ntpdate -b [host]

说明

ntpdate sets the system date and time by querying NTP (Network Time Protocol) servers. It performs a one-time synchronization, unlike ntpd which runs continuously. By default, if the time offset is small, ntpdate gradually adjusts (slews) the clock to avoid disrupting running programs. For large offsets, it steps the clock immediately. The -b flag forces stepping regardless of offset size. Multiple servers can be specified; ntpdate queries all and uses the best response.

参数

-q
Query only; don't set the clock
-u
Use unprivileged port for outgoing packets (useful for firewalls)
-b
Force time to be stepped (abrupt change) rather than slewed (gradual)
-s
Log to syslog instead of stdout
-v
Verbose output
-d
Debug mode; don't change time, show what would happen
-t _timeout_
Timeout for server response in seconds

FAQ

What is the ntpdate command used for?

ntpdate sets the system date and time by querying NTP (Network Time Protocol) servers. It performs a one-time synchronization, unlike ntpd which runs continuously. By default, if the time offset is small, ntpdate gradually adjusts (slews) the clock to avoid disrupting running programs. For large offsets, it steps the clock immediately. The -b flag forces stepping regardless of offset size. Multiple servers can be specified; ntpdate queries all and uses the best response.

How do I run a basic ntpdate example?

Run `sudo ntpdate [host]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -q do in ntpdate?

Query only; don't set the clock