Scope
- By use of Scripting conditions can be added that are checked before a job will be executed.
- Such conditions can include dynamic date calculation to check if the current date is confirmed for execution of a job.
- Scripted conditions are considered more dynamic and flexible than configurable conditions.
Scripted Conditions
- Scripted conditions can be added by use of Pre- and Postprocessing Monitors.
- Each job can be assigned a number of Pre- and Postprocessing Monitors that are executed in the configured sequence.
- The Monitor scripts can include
- Java classes
- JavaScript code
- Scripted conditions are a powerful means for flexibility:
- The JobScheduler exposes its objects, methods and properties by use of the API Interface.
- Find details and examples with the Reference Documentation.
- Scripted conditions can be applied by implementing a
spooler_process_before()
function for a preprocessor Monitor with jobs in a job chain that will- return the value
true
if the job should start, - return the value
false
if the job should not start, - move Orders to the next state in a job chain if the current job should be skipped.
- return the value
Date Calculation
- Date calculation can be performed by use of JavaScript and Java:
- JavaScript provides built-in date calculation capabilities.
- There is always room for improvement. A good example is the date.js library that is
- released under the MIT License and
- available for download at GoogleCode with a
- comprehensible API Documentation.
- Java extends the JavaScript capabilities if used with specific libraries for date calculation.
- Date calculation is an intrinsic topic when considering time zones, daylight saving time, leap years etc. which is why we estimate scripting to be superior to using GUIs when it comes to more complex conditions.
Examples
- Download: date_calculation.zip
- Extract the archive to the hot folder in your JobScheduler installation
./config/live
. - The archive will extract the files to a sub-folder
date_calculation.
- Extract the archive to the hot folder in your JobScheduler installation
- Assigning JavaScript libraries
- The following examples make use of JavaScript with the
date.js
library that can be included with the preprocessing monitors as in the following screenshot. - You could use any JavaScript language capabilities or libaries of your own.
- The following examples make use of JavaScript with the
Run a job on the first week of each month
- The standard job configuration as offered by JOE allows to specify either specific days, e.g. first Monday of a month, or specific dates, e.g. 1st to 7th.
In order to apply both restrictions a scripted condition like this can be used:
Run a job on Thursday and Friday after the 5th and before 15th day of a month
- The standard job configuration as offered by JOE allows to specify either specific weekdays or a range of days.
In order to apply both restrictions a scripted condition like this can be used:
See also
- How to configure a Named Monitor
- How to configure an Enforced Monitor
- How to manage complex conditions to check previous job executions and to start successor job chains