You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Script Jobs in Standard Unix Scripting Languages

Question:

Can I script jobs in standard Unix scripting languages (sh, Perl)?

Answer:

Yes! sh and Perl scripts can be launched as executables.

Even more interesting are scripted jobs that make use of JobScheduler API, e.g.

  • to write to the JobScheduler logs which are visible in JOC, the JobScheduler Operations Center interface (and automatically mail logs in case of errors, warnings or success),
  • to set the job processing state,
  • to launch other jobs via API and to process job parameters.

Scripted jobs with API support are not just launched in a new process, but run in a child instance of JobScheduler which exposes the API objects and methods directly to the script. For the supported scripting languages JobScheduler is linked to the respective language interfaces.

Jobs that make use of the API are preferably written in

  • Java,
  • Javascript, the Mozilla (see SpiderMonkey) runtime environment is included for the above platforms,
  • for Windows additionally VBScript is supported.
  • Perl jobs with API support may be operated for Windows provided that an ActiveState implementation is installed. For Linux and Solaris there are restrictions due to the fact that Perl is not threadsafe implemented, for both platforms we have to link the Perl libraries to the scheduler.
a) Example Standalone Perl Script

The example package of the installation contains the files "scheduler_samples_perlscript.xml" and "sample_script_notification.pl" that show the configuration and implementation for a job named "sample_script_notification". Job starts for this simple script are triggered by changes in the given directory.

b) Example Perl Script using JobScheduler API

The file "sample_api_notification.pl" of the example installation package is a more complete example that demonstrates the usage of JobScheduler API for logging and error handling. This script moves files from one directory to another as soon as they appear and is triggered by directory notification. (this example script was tested for Windows (ActiveState) and Linux with Perl 5.8)

The difference between a) and b) is that a) runs standalone in the command line whereas b) is driven by callbacks from the JobScheduler.

  • No labels