Linux configure batch jobs using at command

Q. How do I configure batch jobs under Fedora Linux?


A. Linux provides batch and at command using at package. You need to install this package to use at and batch command. These commands read commands from keyboard or a specified file which are to be executed at a later time,

=> at – executes commands at a specified time.

=> atq – lists the user’s pending jobs, unless the user is the superuser; in that case, everybody’s jobs are listed. The format of the output lines (one for each job) is: Job number, date, hour, job class.

=> atrm – deletes jobs, identified by their job number.
batch executes commands when system load levels permit; in other words, when the load average drops below 1.5, or the value specified in the invocation of atrun.

To execute a one-time task type batch command:
# batch
Now you will see at> prompt.

Type command and press ctrl+d to save job.

According to man page:
At allows fairly complex time specifications, extending the POSIX.2 standard. It accepts times of the form HH:MM to run a job at a specific time of day. (If that time is already past, the next day is assumed.) You may also specify midnight, noon, or teatime (4pm) and you can have a time-of-day suffixed with AM or PM for running in the morning or the evening. You can also say what day the job will be run, by giving a date in the form month-name day with an optional year, or giving a date of the form MMDDYY or MM/DD/YY or DD.MM.YY. The specification of a date must follow the specification of the time of day. You can also give times like now + count time-units, where the time-units can be minutes, hours, days, or weeks and you can tell at to run the job today by suffixing the time with today and to run the job tomorrow by suffixing the time with tomorrow.

For example, to run a job at 4pm three days from now, you would do at 4pm + 3 days, to run a job at 10:00am on July 31, you would do at 10am Jul 31 and to run a job at 1am tomorrow, you would do at 1am tomorrow.
$ at 1am tomorrow

at> mail < /home/vivek/file.txt

Press ctrl+d to save job.

Reboot system at 5am:
$ at 5am

at> /sbin/reboot

Press ctrl+d to save job.

Read man page of at for more information:
$ man at

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

1 comment… add one
  • Benjamin Misselwitz Mar 22, 2007 @ 9:17

    thank you for the explanation of the batch command. The command worked in my hands, however, I could not change the default load average, even though I entered another value with the atrun -l command, batch kept starting at a value of 0.8. Any suggestions? thank you, Ben

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.