caldelay
programcaldelay program [arg ...]
caldelay
increases $DELAY
as necessary so that the
current time plus $DELAY
seconds will match the description of a
calendar time given by certain environment variables, and then runs the given
command. If $DELAY
is not set, this is interpreted as an
indefinite delay, and caldelay
leaves it unset. Controlling
environment variables include $YEAR
, $MONTH
,
$MONTHDAY
, $WEEKDAY
, $HOUR
,
$MINUTE
, and $SECOND
. All are optional. Each one
that is specified is a list of constraints. All calendar times that satisfy
at least one constraint for each time unit are considered to be matches.
Each constraint must take one of the following forms (otherwise,
caldelay
exits with an error):
/n
: matches times when the given unit is divisible by
n
.
=n
: matches times when the given unit is exactly
n
.
-n
: matches times when the given unit is exactly
m
, where n+m
is one more than the largest value
of the unit. (E.g., n+m=24
for $HOUR
, so
HOUR=-1
is equivalent to HOUR==23
).
Note that /0
is equivalent to =0
, because zero is
divisible by itself.
If a variable is not set in the environment, or is set to an empty string,
the default depends on which others are set. If any larger unit is set, then
the default is =0
; otherwise, the default is /1
.
For example, if $HOUR
is set and no others are, then
$YEAR
, $MONTH
, $MONTHDAY
, and
$WEEKDAY
default to /1
(i.e., no restrictions), and
$MINUTE
and $SECOND
default to =0
.
Thus $DELAY
will be the number of seconds until the next
occurrence of the beginning of the given hour.
$MONTH
and
$MONTHDAY
differ by one from what you might expect.
WEEKDAY==0
is Sunday, MONTH==0
is January, and
MONTHDAY==0
is the first of the month.
$WEEKDAY
together with any of
$YEAR
, $MONTH
, or $MONTHDAY
. The
results will probably not be what you expect, and may be subject to
change in future versions.