← 返回命令列表

Linux command

sntp 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Query time from an NTP server

sntp [pool.ntp.org]

Step (set) the system clock

sudo sntp -S [pool.ntp.org]

Slew (gradually adjust)

sudo sntp -s [pool.ntp.org]

Query using IPv4 only

sntp -4 [pool.ntp.org]

Query using IPv6 only

sntp -6 [pool.ntp.org]

Use reserved NTP port 123

sudo sntp -r [pool.ntp.org]

说明

sntp is a Simple Network Time Protocol client that queries NTP servers and displays the time offset between the local system clock and the server. With appropriate privileges, it can correct the system clock. Unlike the full ntpd daemon, sntp performs one-time synchronization, making it suitable for cron jobs or scripts where continuous synchronization is unnecessary. It can either step (immediately set) or slew (gradually adjust) the clock. Output shows the time offset and error bounds in seconds, indicating how far the local clock deviates from the server.

参数

-S, --step
Step (set) the system clock using settimeofday()
-s, --slew
Slew (gradually adjust) the clock using adjtime()
-4, --ipv4
Force IPv4 DNS resolution
-6, --ipv6
Force IPv6 DNS resolution
-r, --usereservedport
Use reserved NTP port 123 for communication
-M _threshold_
Slew if offset is less than threshold milliseconds, otherwise step
-t _seconds_
Timeout to wait for responses (default: 5)
-d, --debug-level
Increase debug verbosity (can be specified multiple times)
-K _file_, --kod=_file_
KoD (Kiss-of-Death) history file
-a _keyid_, --authentication=_keyid_
Enable authentication with the specified key number
-b _address_
Listen to the specified address for broadcast time sync
-l _file_, --logfile=_file_
Log status messages to the specified file
-c, --concurrent
Send concurrent queries to resolved IPs (for hostnames resolving to multiple addresses on different machines)

FAQ

What is the sntp command used for?

sntp is a Simple Network Time Protocol client that queries NTP servers and displays the time offset between the local system clock and the server. With appropriate privileges, it can correct the system clock. Unlike the full ntpd daemon, sntp performs one-time synchronization, making it suitable for cron jobs or scripts where continuous synchronization is unnecessary. It can either step (immediately set) or slew (gradually adjust) the clock. Output shows the time offset and error bounds in seconds, indicating how far the local clock deviates from the server.

How do I run a basic sntp example?

Run `sntp [pool.ntp.org]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -S, --step do in sntp?

Step (set) the system clock using settimeofday()