Listing 1 Listing
2 Listing 3 Listing
4
A Background Job Launcher
Leor Zolman
In the Premiere issue of SysAdmin, I presented a set of shell scripts that
manage overnight processing of batch jobs. Those scripts, which I collectively
named the "Onite" package, reduce daytime CPU load by offering users
the opportunity to queue resource-intensive programs for execution during late-night
hours.
Some jobs, however, are important enough that they need to be run immediately;
and some programs may require immediate execution in some cases but be suitable
for the overnight queue in others. A framework flexible enough to support such
variations in priority would give users the option, for any particular job,
of either running that job as an immediate background task or queuing it for
overnight processing.
The shell scripts described are the pieces necessary to "upgrade"
the Onite system to provide such a flexible framework. bgrun.sh (Listing 1)
is a general-purpose background task launcher. Lines 7-9 show the usage syntax.
The only required parameter, outfile, specifies the name of a file to which
the standard output stream of the background script is written. If the command
is run as bgrun.sh, outfile receives the standard error stream intermixed with
standard output. If the command is run as bgrun2.sh (by having a link to bgrun.sh
so named), then the standard error stream is not automatically redirected to
outfile; instead, the invoking script is allowed to explicitly direct the standard
error stream to some other file.
|