Content-type: text/html Manpage of getdate

getdate

Section: Maintenance Commands (8)
Updated: getdate
Index
Return to Main Contents
 

NAME

getdate - Get remote RFC 868 date - adjust local time.  

SYNOPSIS

getdate host [ host... ]
getdate -adjust maxinterval maxchange host [ host... ]
getdate -set maxinterval maxchange host [ host... ]

 

DESCRIPTION

Getdate retrieves the current time from a remote host with an RFC 868 compliant time server. Almost any of your favorite Internet hosts (for FTP etc) will provide such a service.

When used to query the time, getdate reports the time on each host to the stdout, along with the difference from local time in seconds.

When used to set the time, getdate tries a list of hosts until one query succeeds or until the list is exhausted. Getdate can use adjtime() to change the time safely, or stime() to change it immediately.

 

OPTIONS

-adjust maxinterval maxchange

The adjust option instructs getdate to call the UNIX adjtime() function. After getdate has called adjtime(), the UNIX kernal will do the rest of the work - the kernal will slowly creep the time to apply the adjustment. This avoids upsetting cron, or any other time sensitive operations (including things like X server input waits).

-set maxinterval maxchange

The adjust option instructs getdate to call the UNIX stime() function to immediately set the time to match the new time. Time should be a monotonically increasing function. Setting it backward or forward in large leaps should be avoided. Cron and other sub-systems relying on the time may become quite upset if you do this to them. Backward movement can be particularly dangerous (especially to X servers).

 

MODIFYING TIME

In order to set the date getdate obtains two samples from each host. It then allows for traveling time by adding half the interval between the pairs of samples to the second sample, which then becomes the new time. Maxinterval and maxchange define the quality of the time and magnitude of the change that you are willing to accept. They are both expressed in seconds.

Getdate will reject a remote host's value if the time between samples exceeds maxintervul seconds. Getdate will also reject a remote host's value if its difference from local time exceeds maxchange seconds. Both these limits are designed to make it safer to run getdate as a cron job. The first limit prevents excessive network or response delays from causing mayhem with the time on your own host. The second limit prevents any large changes propagating to your host (major adjustments should only be done when the machine is in single user mode or some other safe state).

 

EXAMPLES

To query the date at a series of hosts

% getdate tsx-11.mit.edu sunsite.unc.edu sputnik3
tsx-11.mit.edu: (+50) Mon Oct 23 15:32:19 1995
sunsite.unc.edu: (-2) Mon Oct 23 15:31:30 1995
getdate: error - sputnik3 - read error Connection refused

To adjust the local date to a remote date with a maximum interval between samples of one second and a maximum change of sixty seconds

% getdate -adjust 1 60 tsx-11.mit.edu actrix.gen.nz
getdate: tsx-11.mit.edu Mon Oct 23 15:31:16 1995, Mon Oct 23 15:31:18 1995
getdate: info - tsx-11.mit.edu second sample took more than 1 second(s), time not set.
getdate: actrix.gen.nz  Mon Oct 23 15:31:18 1995, Mon Oct 23 15:31:19 1995
getdate: replaced existing adjustment of 5 second(s), 0 usec(s).
getdate: time will adjust slowly by 2 second(s) to match actrix.gen.nz.

To immediately set the local date to a remote date with a maximum interval between samples of 1 seconds and a maximum change of 120 seconds

% getdate -set 1 120 sputnik3
getdate: sputnik3 Mon Oct 23 15:30:29 1995, Mon Oct 23 15:30:32 1995
getdate: set time to Mon Oct 23 15:30:32 1995 to match host sputnik3

You can set up a cron job to adjust your date. The following job script tests to see if ppp is up and adjusts the date if it is, the system clock is also updated to take on the results of any existing adjustments.

#!/bin/sh
if (ifconfig | grep 'ppp0') ; then
        /usr/local/bin/getdate -adjust 2 120 comp.vuw.ac.nz actrix.gen.nz
        /sbin/clock -w
fi

 

BUGS AND LIMITATIONS

This code is definitly not safe from buffer overruns - it is not suid safe.

Please send any bug reports to michael@actrix.gen.nz.

 

AUTHOR

Michael Hamilton (michael@actrix.gen.nz)

 

ACKNOWLEDGEMENTS

Based on rdate by Andy Tefft (teffta@crypt.erie.ge.com) which was based on rdate by Lee Moore at University of Rochester. Thanks are due to d-seaman@ukans.edu, Mitchell B. Hamm, (hamm@one.net) Marty Leisner (leisner@sdsp.mc.xerox.com), and Manuel Mollar Villanueva (mollar@moon.inf.uji.es) for suggestions and patches.

 

COPYRIGHT

Copyright (C) 1995 Michael Hamilton.

Getdate is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
MODIFYING TIME
EXAMPLES
BUGS AND LIMITATIONS
AUTHOR
ACKNOWLEDGEMENTS
COPYRIGHT

This document was created by man2html, using the manual pages.
Time: 10:57:29 GMT, August 25, 1998