Manual pages › System administration commands (1M)
ntpsync(1M)
set the clock from time servers, at boot and hourly
Package: amxbase, added for amigaux.
NAME
ntpsync - set the clock from time servers, at boot and hourly
SYNOPSIS
ntpsync [-b | -c | -n | -i | -l]
DESCRIPTION
ntpsync asks time servers for the time over SNTP, through rdate(1M), sets the clock from the first good answer, and then sets the Amiga's battery clock from it, so that a boot without the network still starts close to the right time. Nothing stays in memory between runs.
It runs at boot, from /etc/init.d/ntp (/etc/rc2.d/S77ntp), in the background: it waits there for ifup(1M) to give an interface its address, so the boot never waits for it. It then runs every hour from root's crontab(1), at a minute picked once for each machine, so that machines do not all ask at the same time.
The servers are asked in this order, each once: the time servers the DHCP server named (option 42, recorded by dhcpc(1M) in the leases it holds now; those of the interface ifup brought up first, first), then rc.conf's ntp_servers. Each server gets ntp_timeout seconds, the name lookup included, and ntp_retries more tries before the next server.
A sync is one line in /var/adm/rc.log, and so is a run that could not sync, whatever the number of servers asked. The hourly run writes a line only when the outcome changes (synced, then not; not, then synced again), so a machine that stays off the network writes one line, not one an hour.
OPTIONS
With no option, sync now: the clock is stepped and the outcome is printed as well as logged. This works with ntp=no too.
- -b
- the boot run: wait up to ntp_wait seconds for the network, then sync, stepping the clock.
- -c
- the hourly run: sync, slewing an offset under a minute with adjtime(2) instead of stepping, so that the clock never goes back: to lose time it stands still until it is right, and to gain it runs fast; it prints nothing.
- -n
- say what would be done: whether the boot and hourly runs are on, the servers in order, the rdate command, the hourly run's minute, and the last outcome.
- -i
- put the hourly line in root's crontab, or take it out, as rc.conf's ntp says; the boot step runs it.
- -l
- print the boot run's time bound in seconds, for the boot step.
RC.CONF KEYS
- ntp=yes|no
- the boot and hourly runs; default yes. With no, the next boot takes the hourly line out of root's crontab, and the hourly run does nothing until then.
- ntp_servers="name ..."
- the servers, after DHCP's; default 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org. A name needs a name server (interfaces(4)'s dns line or a DHCP server's), or a line in /etc/inet/hosts; an address needs neither. A machine with no name server cannot look up the default names and is never set: the log and -n say so. Add a dns line to /etc/inet/interfaces, or addresses to ntp_servers in /etc/rc.conf.
- ntp_timeout=seconds
- the bound of one try at one server; default 15.
- ntp_retries=n
- the tries after the first, at each server; default 1.
- ntp_wait=seconds
- how long the boot run waits for the network; default 120, which is ifup's own bound.
THE BATTERY CLOCK
After a sync, ntpsync waits for the start of the next minute and runs setclk -s, which writes the system time to the battery clock in the zone /etc/clkzone names, to the minute. The setclk of the stock system writes the wrong year after 1999 and is never run; the line in the log says so, and the install's corrected setclk is the one used.
FILES
- /etc/rc.conf
- the keys above.
- /var/inet/dhcpc/interface.lease
- the DHCP server's time servers, in DHCP_NTP.
- /var/inet/ifup.primary
- the interface ifup brought up first; without it there is no network to ask.
- /var/inet/ntp.state
- the last outcome.
- /var/adm/rc.log
- one line for each outcome.
- /var/adm/rclog/ntp
- the boot run's output: each server that did not answer.
- /usr/amiga/bin/setclk
- writes the battery clock.
EXIT STATUS
0 when the clock was set, and for -b and -c with ntp=no; 1 otherwise.
EXAMPLE
# /etc/rc.conf ntp=yes # set the clock from time servers at boot and hourly: ntpsync(1M) ntp_servers="192.0.2.5 time.example.com"
SEE ALSO
dhcpc(1M), ifup(1M), rdate(1M), setclk(1M), crontab(1), rc.conf(4)
NOTES
A machine whose clock is far off (a flat battery) is stepped at boot by the whole difference, and so is one more than a minute off at an hourly run. Password ageing counts days from the clock: see shadow(4) before setting a clock forward by hand.
| 4 November 2026 | amix-base |