Information Technology Reference
In-Depth Information
The at Command
A simple way to execute one or more commands once without modifying a
crontab
is to use the
at(1)
command. Commands submitted for later execu-
tion are grouped together as an at-job and are assigned an at-job ID.
The basic format of the
at
command is
at
time
, where
time
specifies the
time at which the command(s) should be executed. The time can be specified
using any combination of either a.m./p.m. or 24-hour format, plus month
and day in conjunction with the keywords
now
,
today
,
tomorrow
, and so on.
The following listing shows several types of time specifications:
at now
at 10am
at 2pm
at noon
at 3pm + 1 week
at 3pm next week
at 2am jan 24
at 1400 tomorrow
The command(s) to be executed can be entered from the standard
input and ended with Ctrl+D or can be read from a file that is specified by
using the
-f
file
command-line argument. The at-jobs are stored under
the
/var/spool/cron/atjobs
directory, which serves as the
at
queue.
The
at
command supports other command-line arguments to specify that
the commands should be executed using the Bourne shell (
-b
), the C shell
(
-c
), or the Korn shell (
-k
) and whether the user should be notified by mail
when the command is executed (
-m
). Like the
crontab
command, the
at
command supports the
-l
and
-r
command-line arguments and allows
at
-
jobs to be listed and removed by an
at
-job ID.
The
batch(1)
command is equivalent to
at -m now
and allows a batch job to
be entered by means of the standard input.
Use of the
at
and
batch
commands is controlled by the
/etc/cron.d/at.allow
and
/etc/cron.d/at.deny
files. These files function
similarly to the
cron
access control files except that an empty
at.deny
allows
access to everyone.
Note that the
/usr/lib/cron
directory is symbolically linked to the
/etc/cron.d
directory. Therefore, the
at
control files can be accessed using
either pathname.