A tool to synchronize system time from web servers, for linux, windows and macos.
Go to file
Bob Wen 06d6ed87c0 Better request interval 2021-01-29 11:45:41 +08:00
.gitignore Add retry option 2021-01-29 11:35:57 +08:00
LICENSE Initial commit 2021-01-25 11:55:04 +08:00
README.md Update README.md 2021-01-26 09:17:46 +08:00
adjust_time.coffee Change source files attributes 2021-01-25 13:02:04 +08:00
argv.coffee Add retry option 2021-01-29 11:35:57 +08:00
dayjs_format_ms.coffee Change source files attributes 2021-01-25 13:02:04 +08:00
index.coffee Better request interval 2021-01-29 11:45:41 +08:00
median.coffee Change source files attributes 2021-01-25 13:02:04 +08:00
package.json Add retry option 2021-01-29 11:35:57 +08:00

README.md

htpdate

A tool to synchronize system time from web servers, for linux, windows and macos. Download

Examples

Synchronize time from multiple URLs

htpdate -s www.pool.ntp.org www.openssl.org nodejs.org

Query time from multiple URLs

htpdate www.pool.ntp.org www.openssl.org nodejs.org

Change default protocol to 'http'

htpdate -s -p http www.pool.ntp.org

Mix http and https URLs

htpdate -s http://www.pool.ntp.org https://www.openssl.org

Access through a http proxy

export http_proxy=http://127.0.0.1:8118
htpdate -s www.pool.ntp.org

Usage

htpdate [options...] URLs...

Options

 -c, --count            The number of requests for each URL
                        Default: 4

 -C, --command          Command to adjust system time, in https://day.js.org/ display format
                        Default(Linux/Mac): '[date -s ]YYYY-MM-DDTHH:mm:ss.SSSZ'
                        Default(Windows): '[time ]HH:mm:ss.SS[ && date ]YYYY-MM-DD'

 -h, --help             This help text
                        Default: false

 -i, --interval         The minimum milliseconds between requests
                        Default: 500

 -m, --method           HTTP method
                        Default: 'HEAD'

 -p, --protocol         Use this protocol when no protocol is specified in the URL
                        Default: 'https'

 -r, --redirect         If redirect responses should be followed
                        Default: false

 -s, --set              Adjust system time if necessary
                        Default: false

 -t, --threshold        At least how many milliseconds are considered to adjust system time
                        Default: 1500

 -T, --timeout
                        Default: 6000

 -u, --user-agent
                        Default: 'htpdate/1.0.0'

 -v, --version          display the version of htpdate and exit
                        Default: false

Install Precompiled package

Download the precompiled binary package from Releases page, uncompress it, and run it independently as an executable.

Compile

git clone https://github.com/bobwen-dev/htpdate
cd htpdate
npm install
npm run build

License

© 2020 Bob Wen

Licensed under the GNU Affero General Public License v3.0 or later.