Show Table of Contents
23.4. Scheduling a Job to Run on System Load Drop Using batch
To schedule a one-time task, also called a job, to run when the system load average drops below the specified value, use the
batch utility. This can be useful for performing resource-demanding tasks or for preventing the system from being idle.
Users specify
batch jobs using the batch utility. The jobs are then executed by the atd service.
23.4.1. Prerequisites for Batch Jobs
The
batch utility is provided in the at package, and batch jobs are managed by the atd service. Hence, the prerequisites for batch jobs are the same as for at jobs. See Section 23.3.1, “Prerequisites for At Jobs”.
23.4.2. Scheduling a Batch Job
- A job is always run by some user. Log in as the desired user and run:
~]#
batch - At the displayed
at>prompt, enter the command to execute and press Enter:~]#
batchat> sh /usr/local/bin/my-script.shRepeat this step for every command you want to execute.Note
Theat>prompt shows which shell it will use:warning: commands will be executed using /bin/sh
The batch utility uses the shell set in user's SHELL environment variable, or the user's login shell, or/bin/sh, whichever is found first. - Press Ctrl+D on an empty line to finish specifying the job.
Note
If the set of commands or the script tries to display information to standard output, the output is emailed to the user.
Changing the Default System Load Average Limit
By default,
batch jobs start when system load average drops below 0.8. This setting is kept in the atq service. To change the system load limit:
- To the
/etc/sysconfig/atdfile, add this line:OPTS='-l x'
Substitute x with the new load average. For example:OPTS='-l 0.5'
- Restart the
atqservice:#
systemctl restart atq
Viewing Pending Jobs
To view the list of pending jobs, use the
atq command. See the section called “Viewing Pending Jobs”.
Deleting a Scheduled Job
To delete a scheduled job, use the
atrm command. See the section called “Deleting a Scheduled Job”.
Controlling Access to Batch
You can also restrict the usage of the
batch utility. This is done for the batch and at utilities together. See Section 23.3.2.1, “Controlling Access to At and Batch”.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.