
The batch command is used to run a task when the systems load average is less than 0.8%.
The batch command without any options will begin the process of creating a batch job. At the first prompt, you will decide what the batch job will do. In this example, the batch job will execute the script named Example.sh.
[root@server1 ~]# batch
at> sh /home/user1/bin/Example.sh
at> <EOT>
job 1 at Wed Jan 01 17:00:00 2016
Running a script file
Redirection, or the -f option, can be used to run a script file once at a certain date and time.
[root@server1 ~]# batch < /path/to/script.sh
job 2 at Wed Jan 01 18:00:00 2016
[root@server1 ~]# batch -f /path/to/script.sh
job 1 at Thur Jan 02 17:00:00 2016
Viewing the batch queue
The atq or at -l (list) commands can be used to view the at jobs in queue.
[root@server1 ~]# atq
3 Mon Jan 01 01:00:00 2016 a root
2 Mon Jan 01 02:00:00 2016 a root
1 Mon Jan 01 05:00:00 2016 a root
[root@server1 ~]# at -l
3 Mon Jan 01 01:00:00 2016 a root
2 Mon Jan 01 02:00:00 2016 a root
1 Mon Jan 01 05:00:00 2016 a root
Removing a batch job
The at -r (remove), atrm , and at -d (delete) commands can be used to remove a job from the at queue.
[root@server1 ~]# at -r 3
[root@server1 ~]# at -d 3
[root@server1 ~]# atrm 3
[root@server1 ~]# atq
2 Mon Jan 01 02:00:00 2016 a root
1 Mon Jan 01 05:00:00 2016 a root
Change default waiting interval
By default, there will be a 60 second interval between batch jobs. The atd -b n command can be used to change the interval, where n is an integer. For example, to set the interval to 120 seconds.
[root@server1 ~]# atd -b 120
Change default load average
Batch jobs will run when the system load average drops below 0.8%. The top command can be used to view the CPU load average. The atd -l n command can be used to change the load average, where n is an integer. For example, to set the load average to 1.0.
[root@server1 ~]# atd -l 1.0
Did you find this article helpful?
If so, consider buying me a coffee over at