Home | Hardware | Internet News |Web Hosting |IT Management |Network Storage
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials
 News
 Technology Jobs

 Browse by subject.
Free Newsletter

Linux Planet
Linux Today
More Free Newsletters

Be a Commerce Partner


















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Print this article
Email this article

   LinuxPlanet / Tutorials



Major Tom, This is Job Control
Batch Processing and Scheduling

Jay Fink
Thursday, July 27, 2000 10:03:08 AM

Batch processing on Linux means to submit a job that will be run when the system load permits. This is normally when /proc/loadavg is below 1.5 or a value specified by atrun. An example usage of batch is as follows where exec_file.sh is a script we want to run:

  batch 1400 -f exec_file.sh

To check the status of a job the atq utility shows the status of jobs using the at & batch facilities.

Using at is pretty easy but offers a lot of great options. A simple example using the very same exec_file.sh would look like this:

  at -f exec_file.sh 1504

There are some interesting options that go with batch and at. For instance, they both have a default queue priority. The priority scheme is letters from a-z and A-Z. Queues with higher letters run with higher priority. Capitalized queues are treated as if they were submitted at that time. So, to raise the queue priority of our most recent submission, we could do this:

  at -f exec_file.sh -q g 1523

Finally, we can also have the facility mail us with the -m option.

Again, to look at current jobs in the queue use atq. To remove a job the atrm command is used. The job number must be specified. For example, if we wanted to remove job 3:

  atrm 3

Last and definitely not least is cron. The cron facility is primarily for repetitive daily work such as backing up systems, trimming logfiles, running certain applications or other such tasks. The cron facility on many systems vary and have various ways of being implemented. All of them, however, do follow one convention: if you are a cron user, you can simply use the crontab -e command to directly edit a file that will be submitted to crond.

The cron facility reads out the time information from a series of fields on each line of the cronfile. If any of these fields are omitted, it simply truncates from the right. The fields are as follows:

minutes_after_the_hour hours days_of_the_month months_of_the_year weekdays

In other words, to schedule exec_file.sh to run every Monday morning at 3AM our entry would look like so:

  00 3 * * 1 /home/mydir/exec_file.sh 

If there is any possibility of messages being output by a job, it is usually a good idea to redirect it somewhere:

  00 3 * * 1 /home/mydir/exec_file.sh 2>&1

The weekdays start from 0; however, years and months do not.

While this article skimmed over a lot, it is not particularly difficult to get the hang of basic job handling and prioritizing. Just write a practice script and try out all of the scheduling commands.

Next: Combining Commands »

Skip Ahead

1 Acting Nice with the Linux System
2 Batch Processing and Scheduling
3 Combining Commands
4 Okay, Genius, When Does This Come in Handy?





Linux is a trademark of Linus Torvalds.


internet.com home | search | help! | about us

Jupiter Online Media

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers