39.2. At and Batch
While cron is used to schedule recurring jobs, the
atcommand is used to schedule a one-time job at a specific time and the
batchcommand is used to schedule a one-time job to be executed when the systems load average drops below 0.8.
atRPM package must be installed, and the
atdservice must be running. To determine if the package is installed, use the
rpm -q atcommand. To determine if the service is running, use the command
/sbin/service atd status.
39.2.1. Configuring At Jobs
To schedule a one-time job at a specific time, type the command
at time, where
timeis the time to execute the command.
The argument time can be one of the following:
- HH:MM format — For example, 04:00 specifies 4:00 a.m. If the time is already past, it is executed at the specified time the next day.
- midnight — Specifies 12:00 a.m.
- noon — Specifies 12:00 p.m.
- teatime — Specifies 4:00 p.m.
- month-name day year format — For example, January 15 2002 specifies the 15th day of January in the year 2002. The year is optional.
- MMDDYY, MM/DD/YY, or MM.DD.YY formats — For example, 011502 for the 15th day of January in the year 2002.
- now + time — time is in minutes, hours, days, or weeks. For example, now + 5 days specifies that the command should be executed at the same time five days from now.
The time must be specified first, followed by the optional date. For more information about the time format, read the
After typing the
atcommand 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
SHELLenvironment, the user's login shell, or
/bin/sh(whichever is found first).
If the set of commands or script tries to display information to standard out, the output is emailed to the user.
Use the command
atqto view pending jobs. Refer to Section 39.2.3, “Viewing Pending Jobs” for more information.
Usage of the
atcommand can be restricted. For more information, refer to Section 39.2.5, “Controlling Access to At and Batch” for details.