at(1) USER COMMANDS at(1)
NAME
at, batch - execute commands at a later time
SYNOPSIS
at [-f script] [-m] time [date] [+ increment]
at -l [job ...]
at -r job ...
batch
DESCRIPTION
at and batch read commands from standard input to be exe-
cuted at a later time. at allows you to specify when the
commands should be executed, while jobs queued with batch
will execute when system load level permits. at may be used
with the following options:
-f script Reads commands to be executed from the named
script file.
-l [job] Reports all jobs scheduled for the invoking user,
or just the jobs specified.
-m Sends mail to the user after the job has been com-
pleted, indicating that the job is finished, even
if the job produces no output. Mail is sent only
if the job has not already generated a mail mes-
sage.
-r job Removes specified jobs previously scheduled using
at.
Standard output and standard error output are mailed to the
user unless they are redirected elsewhere. The shell
environment variables, current directory, umask, and ulimit
are retained when the commands are executed. Open file
descriptors, traps, and priority are lost.
Users are permitted to use at if their name appears in the
file /etc/cron.d/at.allow. If that file does not exist, the
file /etc/cron.d/at.deny is checked to determine if the user
should be denied access to at. If neither file exists, only
root is allowed to submit a job. If only at.deny exists and
is empty, global usage is permitted. The allow/deny files
consist of one user name per line. These files can only be
modified by the privileged user. If the DATEMSK environment
variable is set, it points to a template file that at will
use to determine the valid time and date values instead of
the values described below. For more information about
using DATEMSK, see the last paragraph of the DESCRIPTION
section.
1
at(1) USER COMMANDS at(1)
time may be specified as follows, where h is hours and m is
minutes: h, hh, hhmm, h:m, h:mm, hh:m, hh:mm. A 24-hour
clock is assumed, unless am or pm is appended to time. If
zulu is appended to time, it means Greenwich Mean Time
(GMT). time can also take on the values: noon, midnight,
and now. at now responds with the error message too late;
use now with the increment argument, such as: at now + 1
minute.
An optional date may be specified as either a month name
followed by a day number (and possibly a year number pre-
ceded by a comma) or a day of the week. (Both the month
name and the day of the week may be spelled out or abbrevi-
ated to three characters.) Two special ``days'', today and
tomorrow are recognized. If no date is given, today is
assumed if the given hour is greater than the current hour
and tomorrow is assumed if it is less. If the given month
is less than the current month (and no year is given), next
year is assumed.
The optional increment is simply a number suffixed by one of
the following: minutes, hours, days, weeks, months, or
years. (The singular form is also accepted.) The modifier
next may precede the increment; it means ``+ 1.''
Thus valid commands include:
at 0815am Jan 24
at 8:15am Jan 24
at now + 1 day
at now next day
at 5 pm Friday
at and batch write the job number and schedule time to stan-
dard error.
at -r removes jobs previously scheduled by at or batch. The
job number is the number returned to you previously by the
at or batch command. You can also get job numbers by typing
at -l. You can only remove your own jobs unless you are the
privileged user. If the environment variable DATEMSK is
set, at will use its value as the full path name of a tem-
plate file containing format strings. The strings consist
of field descriptors and text characters and are used to
provide a richer set of allowable date formats in different
languages by appropriate settings of the environment vari-
able LANG or LCTIME (see environ(5)). (See getdate(3C) for
the allowable list of field descriptors; this list is a sub-
set of the descriptors allowed by calendar(1) that are
listed on the date(1) manual page.) The formats described
above for the time and date arguments, the special names
noon, midnight, now, next, today, tomorrow, and the
2
at(1) USER COMMANDS at(1)
increment argument are not recognized when DATEMSK is set.
EXAMPLES
The at and batch commands read from standard input the com-
mands to be executed at a later time. sh(1) provides dif-
ferent ways of specifying standard input. Within your com-
mands, it may be useful to redirect standard output.
This sequence can be used at a terminal:
batch
sort filename > outfile
<control-D> (hold down `control' and depress `d')
This sequence, which shows redirecting standard error to a
pipe, is useful in a shell procedure (the sequence of output
redirection specifications is significant):
batch <<!
sort filename 2>&1 > outfile | mail loginid
!
To have a job reschedule itself, invoke at from within the
shell procedure, by including code similar to the following
within the shell file:
echo "sh shellfile" | at 1900 thursday next week
The following example shows the possible contents of a tem-
plate file AT.TEMPL in /var/tmp.
%I %p, the %est of %B of the year %Y run the following job
%I %p, the %end of %B of the year %Y run the following job
%I %p, the %erd of %B of the year %Y run the following job
%I %p, the %eth of %B of the year %Y run the following job
%d/%m/%y
%H:%M:%S
%I:%M%p
The following are examples of valid invocations if the
environment variable DATEMSK is set to /var/tmp/AT.TEMPL.
at 2 PM, the 3rd of July of the year 2000 run the following job
at 3/4/99
at 10:30:30
at 2:30PM
FILES
/etc/cron.d main cron directory
/etc/cron.d/at.allowlist of allowed users
/etc/cron.d/at.deny list of denied users
/etc/cron.d/queuedefsscheduling information
3
at(1) USER COMMANDS at(1)
/var/spool/cron/atjobsspool area
SEE ALSO
atq(1), atrm(1), calendar(1), crontab(1), date(1), kill(1),
mail(1), nice(1), ps(1), sh(1), sort(1).
cron(1M), environ(5), in the System Administrator's Refer-
ence Manual.
getdate(3C) in the Programmer's Reference Manual.
DIAGNOSTICS
Complains about various syntax errors and times out of
range.
4