← 返回命令列表

Linux command

htpdate 命令

安全

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

常用示例

Synchronize

sudo htpdate [host]

Example

htpdate -q [host]

Compensate

sudo htpdate -x [host]

Example

sudo htpdate -s [host]

说明

htpdate synchronizes the local system time using HTTP headers from web servers. It extracts the Date header from HTTP responses, providing time synchronization without dedicated NTP ports. This is useful in restricted network environments where: - NTP (port 123) is blocked by firewalls - Only HTTP/HTTPS traffic is allowed - Time synchronization is needed but NTP servers are inaccessible htpdate can query multiple servers and average the results for better accuracy. It supports both one-time synchronization and daemon mode for continuous adjustment.

参数

-q
Query only; don't set time
-s
Set time immediately (step)
-x
Adjust for systematic drift
-a
Adjust time gradually (slew)
-d
Run as daemon
-l
Use syslog for logging
-t
Turn off sanity time check
-u _USER_
Run as specified user
-p _FILE_
Create PID file

FAQ

What is the htpdate command used for?

htpdate synchronizes the local system time using HTTP headers from web servers. It extracts the Date header from HTTP responses, providing time synchronization without dedicated NTP ports. This is useful in restricted network environments where: - NTP (port 123) is blocked by firewalls - Only HTTP/HTTPS traffic is allowed - Time synchronization is needed but NTP servers are inaccessible htpdate can query multiple servers and average the results for better accuracy. It supports both one-time synchronization and daemon mode for continuous adjustment.

How do I run a basic htpdate example?

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

What does -q do in htpdate?

Query only; don't set time