Linux configure batch jobs using at command

Get real time updates directly on you device, subscribe now.

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 [email protected] < /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

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Get real time updates directly on you device, subscribe now.