At and Batch
While cron is used to schedule recurring tasks, the at
command is used to schedule a one-time task at a specific time and the batch
command is used to schedule a one-time task to be executed when the systems load average drops below 0.8.
To use To schedule a one-time job at a specific time, type the command The argument The time must be specified first, followed by the optional date. For more information about the time format, read the After typing the If the set of commands or script tries to display information to standard out, the output is emailed to the user.
Use the command Usage of the To execute a one-time task when the load average is below 0.8, use the After typing the If the set of commands or script tries to display information to standard out, the output is emailed to the user.
Use the command Usage of the To view pending Additional command line options for The The root user can always execute If the file If To start the at
or batch
, the at
RPM package must be installed, and the atd
service must be running. To determine if the package is installed, use the rpm -q at
command. To determine if the service is running, use the command /sbin/service atd status
.
Configuring At Jobs
at
, where time
is the time to execute the command.
time
time
can be one of the following:
/usr/share/doc/at-
text file.
<version>
/timespecat
command with the time argument, the at>
prompt is displayed. Type the command to execute, press Enter, and type Ctrl+D . Multiple commands can be specified by typing each command followed by the Enter key. After typing all the commands, press Enter to go to a blank line and type Ctrl+D . Alternatively, a shell script can be entered at the prompt, pressing Enter after each line in the script, and typing Ctrl+D on a blank line to exit. If a script is entered, the shell used is the shell set in the user's SHELL
environment, the user's login shell, or /bin/sh
(whichever is found first).
atq
to view pending jobs. Refer to "Viewing Pending Jobs" for more information.
at
command can be restricted. For more information, refer to "Controlling Access to At and Batch" for details.Configuring Batch Jobs
batch
command.
batch
command, the at>
prompt is displayed. Type the command to execute, press Enter, and type Ctrl+D . Multiple commands can be specified by typing each command followed by the Enter key. After typing all the commands, press Enter to go to a blank line and type Ctrl+D . Alternatively, a shell script can be entered at the prompt, pressing Enter after each line in the script, and typing Ctrl+D on a blank line to exit. If a script is entered, the shell used is the shell set in the user's SHELL
environment, the user's login shell, or /bin/sh
(whichever is found first). As soon as the load average is below 0.8, the set of commands or script is executed.
atq
to view pending jobs. Refer to "Viewing Pending Jobs" for more information.
batch
command can be restricted. For more information, refer to "Controlling Access to At and Batch" for details.Viewing Pending Jobs
at
and batch
jobs, use the atq
command. The atq
command displays a list of pending jobs, with each job on a line. Each line follows the job number, date, hour, job class, and username format. Users can only view their own jobs. If the root user executes the atq
command, all jobs for all users are displayed.Additional Command Line Options
at
and batch
include:
Table 37.1.
at
and batch
Command Line Options
Option
Description
-f
Read the commands or shell script from a file instead of specifying them at the prompt.
-m
Send email to the user when the job has been completed.
-v
Display the time that the job is executed. Controlling Access to At and Batch
/etc/at.allow
and /etc/at.deny
files can be used to restrict access to the at
and batch
commands. The format of both access control files is one username on each line. Whitespace is not permitted in either file. The at
daemon (atd
) does not have to be restarted if the access control files are modified. The access control files are read each time a user tries to execute the at
or batch
commands.
at
and batch
commands, regardless of the access control files.
at.allow
exists, only users listed in it are allowed to use at
or batch
, and the at.deny
file is ignored.
at.allow
does not exist, users listed in at.deny
are not allowed to use at
or batch
.Starting and Stopping the Service
at
service, use the command /sbin/service atd start
. To stop the service, use the command /sbin/service atd stop
. It is recommended that you start the service at boot time. Refer to Controlling Access to Services for details on starting the cron service automatically at boot time.