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

Compare with Current View Page History

« Previous Version 36 Next »

Introduction

Previous tutorials in this series have described the configuration and use of Order Jobs. However, there is another route to starting tasks with JobScheduler ....
First of all, a little background information ....

Standalone Jobs and Order Jobs

JobScheduler comes with two types of job that can be used to carry out workflow automation tasks - Standalone Jobs and Order Jobs.

Standalone Jobs are simple to configure and are often used in simpler job scheduling environments. They are also often used where users have migrated from other job scheduling systems such as TWS which are based on a similar concept. However, Standalone Jobs are neither as flexible nor as powerful as Order Jobs.

Order Jobs are run in Job Chains and can be executed both sequentially and in parallel. Order Jobs require an Order before they can run. Orders are triggers that start a Job Chain and convey information about the state in the job chain corresponding with the job that is being run. Orders can also have a payload of parameters that are processed by individual Jobs. These concepts are explained in more detail in our Concepts for jobs, job chains and orders article. In addition, our Job Chains article illustrates some of the basic Job Chain patterns that can be implemented with JobScheduler.

This tutorial is  intended to provide a quick and compact introduction to configuring and running Standalone Jobs on the JobScheduler.
A detailed step-by-step guide to configuring and running Order Jobs can be found in our other Tutorials.

Required Knowledge

Before you start to work through the examples in this document, we strongly recommend that you take the time to become familiar with some of the other JobScheduler documentation, in particular, the Installation and Configuration guide (scheduler_installation).
Note that a quick overview of the JobScheduler documentation has been included at the end of this article.

How are Jobs, Job Chains and Orders Configured?

  • JobScheduler objects (jobs, job chains, orders, schedules, process classes and locks) are all configured using plain XML files. These files are saved in the so-called Live Folder (the default location of this folder or directory is ./config/live, relative to the scheduler_data directory). The configuration for every JobScheduler object is saved individually in this folder or one of its  sub-folders.
  • Changes to these object configuration files become effective without a restart of the JobScheduler being necessary, although on Unix® systems it may take up to a minute for a change to become effective.
  • Objects can be created and modified using JOE - JobScheduler Object Editor. New objects are created by either opening an already existing configuration file in JOE, modifying it and then saving the file under a new name, or by creating and configuring a completely new file.

Other tutorials in this series

Getting Started

  1. Create a subdirectory named standalone_jobs within the Live folder (./config/live) directory for the JobScheduler objects described in this article.
  2. Start JOE (JobScheduler Object Editor) using one of the following scripts:
    • %SCHEDULER_HOME%\bin\jobeditor.cmd ( Windows™ )
    • $SCHEDULER_HOME/bin/jobeditor.sh ( Unix™ )
  3. Use the key combination ctrl+D to open the live folder in JOE .
    You can also open this dialog by selecting File -> Open Hot Folder from the menu or by clicking the red folder icon.
    The live folder should have been selected by default: if not, navigate to ./config/live. Select the standalone_jobs sub-folder.
    If required you can also use this dialog to create the standalone_jobs subdirectory.
  4. Open JOC  - the JobScheduler Operations Center.
    You can use JOC to follow changes to Jobs and other objects as they happen.
    You open JOC in a browser by entering the address http://[scheduler_host]:[scheduler_port], where [scheduler_host] and [scheduler_port] are the host name and the TCP port number of the JobScheduler (e.g. http://localhost:4444). Note that the JobScheduler must be running before JOC is called.
    The screenshot below shows JOC as it opens with the default Jobs tab selected.
    Activate the Update checkbox in the center of the header bar to automatically refresh the page every 5 seconds.

Setting up a Standalone Job

Have you finished making the steps described in the Getting Started section above? Then we can continue.

... Do It Yourself

The JobScheduler object tree is shown in the left hand pane of the screenshot below. Click on the Jobs element in this tree and then click on the New Standalone Job button in the right hand pane. A new Job will now be added. This will be shown in both the left hand element tree and the list of jobs in the main pane. Click on this new job.

This will open the Job configuration element as shown in the next screenshot. Give this job a name by entering, for example, firstJob in the Job Name field. Note that for standalone Jobs the Stop On Error checkbox to be activated (in the Options tab in JOE when Jobs->firstJob is selected; see also Error Handling below). Now enter a shell script such as the following in the Source Code text field:

Example: for Microsoft® Windows®
@echo off
echo  %SCHEDULER_JOB_NAME% is  running 
echo  Current Timestamp:  %DATE% %TIME%
exit %ERRORLEVEL% 
Example: for Unix®
#!/bin/sh
echo  "$SCHEDULER_JOB_NAME is running"
echo  "Current Timestamp:  `date`"
exit $?

 

Note that a Start Period or Parameters can also be allocated to a Job (see below).

Now save this configuration, either using the ctrl+S keys or File->Save, and JOE will create the ./config/live/standalone_jobs/firstJob.job.xml file.

Now change to JOC and update the window using the Update button at the very top of the window. You will now see the standalone_jobs/firstJob Job in the Jobs tab.

Click on the Job in the left hand part of the window to open a detailed view of the Job in the right hand part. Start a task for this Job by clicking on ->Start task immediately  in the Job menu, as shown in the screenshot below.

The task will now start to run and you can follow its progress in the Task history by clicking on the current task history entry as shown in the next screenshot.

This will open a new browser window with the log output, where, amongst other things, you will be able to read the output from the shell script.

Congratulations!

You have successfully configured and run your first Standalone Job.

Scheduled Job Starts

In the following example a Standalone Job is configured to start daily at 12:00 o'clock and at 14:00.

You will find the Run Time->Everyday function in the element tree in the left hand pane of JOE: this is a sub-element available for both Jobs and Orders. Use the New Period button (positioned on the right hand side) to add a new start period. Use the Apply Period button to save your input after you have selected Single Start  12:00:00 in the Start Time field. Repeat this procedure for Single Start 14:00:00.

Note that in addition to the fixed start times (Single Start), it is also possible to set the following starting modes:

  • repeat intervals (Interval end/start, Interval start/start).
  • run-time period when a Job is to be started outside of the Job's time period, the Job will be queued and started once its run-time period has been reached.TO CHECK

Standalone Jobs can still be started manually, regardless of whether a start time or run period has been set. It is also possible to combine the scheduled starting of a Standalone Job with Directory Monitoring.

Configuration as XML

The code used to specify the firstJob job at the times specified in schedule1 and with the Directory Monitoring also described is shown in the code block below:

Configuration of firstJob with Run Time
<spooler>
  <config>
    <jobs>
      <job name="firstJob">
        <script language="shell"><![CDATA[@echo off
echo  %SCHEDULER_JOB_NAME% is  running echo  Current Timestamp:  %DATE% %TIME%
exit %ERRORLEVEL%]]></script>
        <run_time>
          <weekdays>
            <day day="1 2 3 4 5 6 7">
              <period single_start="12:00" />
              <period single_start="14:00" />
            </day>
          </weekdays>
        </run_time>
      </job>
    </jobs>
  </config>
</spooler>

Further References

A Overview of the JobScheduler Documentation

  • No labels