Manual pages › System administration commands (1M)
rdate(1M)
set the clock from a time server
Package: rdate, added for amigaux.
This package comes with every 1.1 install; without it, rdate is the original one: see rdate-original(1M).
NAME
rdate - set the clock from a time server
SYNOPSIS
/opt/amix/sbin/rdate [ -46anpsuv ] [ -t sec ] [ -r n ] [ -b sec ] [ -d msec ] [ -o port ] host ...
DESCRIPTION
rdate asks a time server for the time and sets the system clock from it. With -n it speaks SNTP (RFC 5905) to UDP port 123, which every public time server answers; without it, the older RFC 868 time protocol to TCP port 37. Each host is tried in turn until one gives a usable time. When a name has several addresses, the next one is tried if one fails outright; a silent address takes the whole try.
Every try is bounded: the name lookup, the connection and the exchange together get -t seconds, after which the try is given up, so neither a silent network nor a name server that does not answer can hold rdate up. A host is tried -r more times before the next one. For one host the longest rdate can take is (n+1) × sec seconds, and about one more.
Within a try, -n asks a silent server again after 2 seconds, then after 4, doubling each time, but not once fewer than 2 seconds of the try are left. With the default -t, that is three datagrams, at 0, 2 and 6 seconds, and with the default -r six per silent server in a run. A reply to any of them counts, however late, and the first good one ends the try, so a server that answers is not asked again and a slow answer still sets the clock.
The clock is stepped with settimeofday(3), which sets it through stime(2) to the whole second (a fraction of half a second or more rounds up), or, with -a, slewed with adjtime(2), which runs the clock slightly fast or slow until the difference is gone. Setting the clock needs root; -p does not.
rdate has no configuration file and runs no daemon. The base system's ntpsync(1M) runs it at boot and every hour, with the servers named in /etc/rc.conf.
OPTIONS
- -n
- Use SNTP. The reply is checked: the server's mode, a version from 1 to 4, the random cookie of a request of this try echoed back, a stratum from 1 to 14, and a leap indicator other than 3 (not synchronised). One good reply is enough. A stratum of 0 is a kiss-o'-death, by which a server asks its clients to stop or slow down: it is refused and that host is not asked again.
- -t sec
- The time allowed for each try, the name lookup included (default 15).
- -r n
- How many more times to try a host before the next one (default 1). A name that does not resolve, or a server that refused, is not tried again.
- -a
- Slew the clock with adjtime(2) instead of stepping it, when the difference is at most -b seconds (default 60 with -a); a bigger difference is stepped.
- -b sec
- Step the clock when the difference is more than sec seconds, slew it otherwise. -b 0 with -a always slews.
- -d msec
- Leave the clock alone when the exchange took more than msec milliseconds.
- -p
- Print the time and the difference, but do not set the clock.
- -s
- Do not print the date.
- -v
- Also print the difference applied, as described under OUTPUT.
- -u
- Use UDP for the RFC 868 protocol.
- -o port
- Use port instead of 123 or 37.
- -4
- Use IPv4 addresses, the only ones this system has.
- -6
- Use IPv6 addresses: on this system the lookup fails.
OUTPUT
On success, rdate prints the new date to the standard output, unless -s is given, and, with -v, -p or -a, one line
rdate: adjust local clock by -12.482113 seconds (192.0.2.1)
naming the difference and the address that answered. When -b decided, the line says (adjtime) or (instant change) before the address. On a failure it prints one line to the standard error for each host that gave no usable time, such as
rdate: 0.pool.ntp.org: no usable answer in 15 s (2 tries) rdate: time.example: host not found rdate: 192.0.2.1: refused: stratum 0 (kiss-o'-death RATE)
EXIT STATUS
- 0
- The clock was set, or with -p, the time printed.
- 1
- Another failure: a socket error or, with the RFC 868 protocol, a refused connection.
- 2
- A usage error.
- 3
- The name did not resolve.
- 4
- No usable answer within -t seconds, on any try. With -n that includes no route to the server and a closed port: this system reports neither to a program sending UDP.
- 5
- The server's reply was refused (kiss-o'-death, not synchronised).
- 6
- The exchange took longer than -d.
- 7
- Setting the clock failed (not root, or the system refused).
With several hosts, the status is the last host's.
EXAMPLES
What ntpsync(1M) runs at boot, which steps the clock:
/opt/amix/sbin/rdate -n -s -v -t 15 -r 1 0.pool.ntp.org 1.pool.ntp.org
and every hour, which slews a small difference so that the clock never runs backwards under cron(1M):
/opt/amix/sbin/rdate -n -a -s -v -t 15 -r 1 0.pool.ntp.org 1.pool.ntp.org
To look without changing anything:
rdate -n -p pool.ntp.org
SEE ALSO
NOTES
Names resolve as the system's resolver does: with DNS off (the default of a stock system), only /etc/hosts is read, and a pool name fails at once with host not found.
The SNTP arithmetic keeps NTP's 64-bit fixed point and takes differences modulo 2^64, so a clock up to 68 years wrong (such as one the battery clock never set, in 1977) is set correctly, also across NTP's 2036 era change. The program has no floating point, so it runs on an FPU-less 68LC040 or 68LC060 without the kernel's emulator.
This kernel's adjtime(2) slews at about one second per second: to gain, the clock runs about twice as fast; to lose, it stands still until the difference is gone, and never runs backwards. A slew of 20 seconds takes about 20 seconds, during which a lost second is a second in which the clock does not move; hourly differences are fractions of a second.
A step is not recorded in /var/adm/wtmp as date(1) records one.
| 4 November 2026 | rdate 1.11 |