HTP in Perl
A ntpdate lookalike is available, which does a one-time time synchronisation to a web server of your choose. Since version 0.9.1 also a htpd ("ntpd") time daemon is available. Both time clients are written in Perl and provides time synchronisation support for HTTP/HTTPS websites (depending on your Perl LWP module installation) optional via a proxy server. Support for proxy servers that require (basic) authentication is supported since 0.9.1.
# ./htpdate -h
Usage: ./htpdate [-dhqx]
-h show this help
-x do not set the time (only show)
e.g. ./htpdate -x http://www.microsoft.com
# ./htpdate http://www.microsoft.com
http://www.microsoft.com => 7 seconds
Time is set to Wed Aug 25 20:54:41 2004
For good accuracy choose a web server close to you.
The execution of this htpdate script could be automated in a cron entry or be part of an init script run at boot time. Be aware that the script makes a step in time and some programs (e.g. database) do not always appreciate a step backwards in time. The C version of htpdate doesn't step but adjusts the time smoothly.
Htpdate has been tested with Cygwin and Linux, but should work on any platform with Perl (and LWP modules). In many Perl distributions LWP is included by default. A version written in C is located here
A htpd daemon version - ntpd lookalike - is available since version 0.9.1. Htpd handles responses of multiple web servers and chooses the best of the list to synchronize with. The polling interval of htpd increases and decreased automatically as needed.
Current release - daytime, htpdate, htpdate-light, htpd
# ./htpd -d
Number of the succesfull hits 6
- 2 http://www.microsoft.com
* 1 http://www.ntp.org
- 0 http://www.perl.org
* 1 http://www.samba.org
* 1 http://www.ibm.com
* 1 https://www.redhat.com
Next poll in about 7200 seconds
For previous releases look in the archive