Current Issue


Table of contents

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 12.0

Version 12.0 delivers every issue of Sys Admin from 1992 through 2006 and every
issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!

Sys Admin Magazine > Archives > 2005 > August 2005
SysAdminMag.com

Queuing Jobs with qjob

Ed Schaefer and John Spurgeon

Sidebar: Semaphore Options

Most systems administrators are familiar with using the cron facility or the at command to schedule jobs. Sometimes an attempt is made to schedule jobs so they don't conflict with one another. For example, it may be necessary to limit the number of resource-intensive jobs running at the same time to avoid overloading the system. Or you may need to prevent jobs from simultaneously accessing a shared resource. This can be challenging, especially if commands must be run frequently and the time they take to complete is significant and variable.

One solution is to create a wrapper script that executes commands in series. This can solve the problem if there is a way to guarantee that only one instance of the wrapper script executes at a time. However, the situation becomes more complicated if some jobs need to be run more often than others.

We've developed a shell script called qjob (Listing 1), which places jobs in a FIFO queue and executes them when they are removed from the queue. This simplifies the scheduling problem and gives you more flexibility than a wrapper script. With qjob, you can configure how many jobs are allowed to run at once for a given queue. If only one job can run at a time, then the queue is analogous to a checkout lane at a supermarket where all the customers wait while a cashier services the person at the head of the line. If more than one job can run at once, then the queue behaves like a single line at a bank with multiple tellers servicing customers simultaneously.

Options

The following options are supported by qjob:

-j job_name -- job_name is an alias that identifies the command to be executed.




MarketPlace

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.

Six Sigma Certification
100% Online-Six Sigma Certificate from Villanova - Find Out More Now.

Workflow Enabled Help Desk & IT Service Management
Automate service desk activities and integrate processes across IT. Learn more here.

Flowcharts from C/C++ code -- Free trial download
Understand C/C++ code in less time. A new team member ? Inherited legacy code ? Get up to speed faster with Crystal Flow for C/C++. Code-formatting improves readability. Flowcharts are integrated with code browser. Export flowcharts to Visio.

Wanna see your ad here?