OPEN SOURCE - Job Scheduler - Solutions

Job Scheduler
 
 

You could be interested in this: HOW TOs!

HOW TOs contain ready-to-run configuration examples which can be downloaded and deployed in the hot folders of a Job Scheduler installation. The HOW TOs are sample solutions that have been written for individual tasks, the solutions are described in more detail than the FAQs. Read more about the sample solutions: HOW TOs

 

 
 
Job Scheduler - Frequently Asked Questions
 
Getting Started Trouble Shooting Database Support Licence and Support All the Rest
 
 
 
 
Creating a Job
 
Question:
How do I go about creating a job in order to launch a shell program every hour?

Answer:
a job element must be inserted in the configuration file config/scheduler.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<spooler>
  <config>
    <jobs>

       <job name = "my_shell_script">
          <process file  = "my_shell_script.sh"
                   param = ""/>
          <run_time repeat = "3600"
                    begin  = "00:00"
                    end    = "24:00"/>
       </job>

     </jobs>
   </config>
</spooler>
              
The job named my_shell_script will be started every hour (see <run_time repeat=...>) and will execute the script my_shell_script.sh (see <process file=...>).

 

top of page
 
Job Dependencies
 
Question:
Can job dependencies be defined for the Job Scheduler?

Answer:
  1. Using job chains

    Sequences of jobs can easily be configured in job chains that guarantee that a successor job is not invoked if a previous job provokes an error. Job errors can be configured to be detected by execution code (for executable files), signals (for Unix only), availability of output to stderr and by errors that were raised either by API methods or by SQL exceptions (and normal SQL errors).

    Job chains are nodes of jobs that are organized in a sequence, every node is given a distinct state. An order proceeds along the jobs in a job chain one after the other. Should a processing error occur, then the order is stopped and removed from the job chain.
    See the samples in What is the concept of "job chains and order processing"?

    In addition to this you could use monitor scripts to implement more complex conditions for job starts in any of the languages Java, Javascript, Perl and VBscript. The Job Scheduler API provides a method scheduler_job.start() that can be used in scripts that implement their own business logic for conditional job starts.

    Moreover this API method can be exposed to Oracle pl/sql procedures or functions (by Java classes in the database) that enable jobs to be launched in a transactional environment (e.g. start a job exlusively after commit has been invoked) either by triggers or by pl/sql procedures.

  2. Using successor jobs

    You could configure any jobs to succeed the current job based on it's execution result:
    <job>
      <process file="..."> or <script language="...">
        <!-- in case of success the exit code=0, let's start this job -->
        <commands on_exit_code="success">
          <start_job job="ftp_get_files"><params/></start_job>
        </commands>
        <!-- in case of error the exit code!=0 -->
        <commands on_exit_code="error">...</commands>
        <!-- other exit codes could be handled individually -->
        <commands on_exit_code="1 2 4 8">...</commands>
      </process>
    </job>
    
    You could configure any job to start arbitrary successor jobs and orders from Job Scheduler release 1.2.7 on.

 

top of page
 
Job Initiation
 
Question:
What type of events are available to initiate jobs (e.g. presence of a file)?

Answer:
Jobs can be configured to start after the following events:
  • file system events: file has been added deleted; file names to be triggered can be configured as regular expressions;
  • calendar events: a given date, weekday, day of month, ultimo; these events can be configured to respect holidays;
  • API events: use of the API method spooler_job.start(); this method can be used by other jobs in any of the languages Java, Javascript, Perl, VBScript;
  • XML commands sent to the Job Scheduler via TCP/IP or UDP datagrams. Jobs can be started, stopped (and otherwise controlled) by simple XML commands, e.g.
    <start_job job="cleanup_tmp_files" at="now">.
  • events created by the web interface of the Job Scheduler: these events use the above XML commands.


 

top of page
 
Scheduling for Multiple Jobs
 
Question:
Can multiple jobs be scheduled to run simultaneously with priority assigned?

Answer:
Multiple jobs (<1000) can run simultaneously and jobs kann run in multiple processes, if they are implemented to do so. Example: you could run one database statement per job and let these jobs run simultaneously; or you could run a maximum of e.g. 10 simultaneous processes of a standard job that handles any database statement or executable file - in this case an order is assigned to the job that contains the sql statement or filename in its payload (see answer: Job Streams).

Jobs can be configured to start with priorities by <job priority="..."/>. Use of priorities is operating system dependent, see priorities. Operating system prioritities have no effect on database driven jobs that spend their lifetime in the database (server).

Moreover process classes can be assigned to jobs in order to limit the number of parallel tasks in a specified process class. If all tasks are running then a job will wait for the next free task and therefore be serialized.

 

top of page
 
Parameter Sets for Multiple Jobs
 
Question:
How to identify specific parameter sets for multiple jobs with same name?

Answer:
If multiple jobs share the same job implementation then every job can have its own parameter sets. See this example:

<job name = "cleanup_sos_files" title = "Remove temporary files">
  <params>
    <!-- remove temporary files from the given directory otherwise 
    from the users temp directory  --> 
    <param name = "file_path" value = "/tmp"/> 
    <!-- remove temporary files with the given prefix --> 
    <param name = "file_specification" value = "^(sos.*)"/> 
  </params> 
  <script language = "java"
          java_class = "sos.scheduler.job.JobSchedulerCleanupFiles"/> 

  <!-- cleanup files in the given interval of seconds (4 hours) --> 
  <run_time let_run = "yes"
            begin   = "06:00"
            end     = "22:00"
            repeat  = "04:00:00"/> 
</job> 


<job name = "cleanup_tmp_files" title = "Remove temporary files"/> 
  <params/> 
    <param name = "file_path" value = "/tmp"/> 
    <param name = "file_specification" value = "^(tmp.*)"/> 
  </params/> 

  <script language = "java"
          java_class = "sos.scheduler.job.JobSchedulerCleanupFiles"/> 

  <!-- cleanup files in the given interval of seconds (24 hours)--> 
  <run_time let_run= "yes"
            begin   = "00:00"
            end     = "24:00"
            repeat  = "24:00:00"/> 
</job> 
              
 

top of page
 
Job Streams
 
Question:
How would the product handle a sample job stream?

Answer:
Job streams (we call them: job chains) are arranged by XML job configuration, by using the web interface or API methods in individual programs: firstly you create a job chain and the jobs that are part of this chain. Every position in a job chain is assigned a state and a job.

Then you create an order, i.e. a simple token, that is assigned a state in a job chain (normally the beginning of a job chain). Optionally an order has a payload consisting of parameters that are processed by the jobs. When an order is added to the job chain, it is enqueued by the Job Scheduler according to the state of the order. The job assigned to this position then carries out the order.

Additionally, each position in a job chain has a successor state and an error state. The Job Scheduler changes the state of an order after each job in the job chain has been processed. If the job step was successful, then the Job Scheduler sets the successor state; otherwise it sets the error state. The order then moves to another position in the job chain as defined by the new state.

Jobs within a job chain can be executed in multiple processes to handle parallel processing of orders.

 

top of page
 
Notification on Job Completion
 
Question:
What possibilities for notification on job completion and in case of problems are available?

Answer:
Notification is done by mail. The Job Scheduler sends configurable (to, cc, bcc) mails for the following events:
  • mail_on_error
  • mail_on_warning
  • mail_on_success
  • mail_on_process (reserved for API based jobs)


All mails have an attached log file of the job or the order that was processed. The log files contain output to stdout and stderr, SQL errors and dbms_output from Oracle and any messages (info, warning, error, debug) that were created by API methods.

 

top of page
 
Delayed and Repeated Processing
 
Question:
What features are available to delay processing of jobs (sleep/wake)?

Answer:
The following delays are implemented:
  • A simple way to make a job sleep and wake up is to configure a repeat interval in hours, minutes and seconds. In this case the job is not exactly "delayed" but will be restarted as soon as the interval has elapsed.

  • A job can delay its processing by the Job Scheduler API method delay_spooler_process(seconds_or_hhmmss). This is available only if the job implements the method spooler_process() of the API. In this case the job remains loaded, i.e. it is in processing but uses no CPU until the scheduled interval has elapsed.

  • A job can be configured for restart should an error have occurred, for example by configuration or API methods:

    spooler_job.delay_after_error( 2 ) = 10; // 10 seconds
    spooler_job.delay_after_error( 5 ) = "00:01"; // one minute
    spooler_job.delay_after_error( 10 ) = "24:00"; // one day
    spooler_job.delay_after_error( 20 ) = "STOP";


    In this example, the Job Scheduler repeats a job immediately after a (first) error occurs. After two to four consecutive errors, however, the Job Scheduler delays restarting the job by 10 seconds; between five and nine consecutive errors, the delay is one minute; between ten and nineteen errors, it is 24 hours. The job is stopped after the twentieth consecutive error.

    It is possible to set the value of the seconds_or_hhmm_ss parameter to "STOP" in order to restrict the number of (unsuccessful) repetitions of a job. The job then is stopped, i.e. will not restart automatically, when the number of consecutive errors specified is reached.

 

top of page
 
Viewing Job Schedules
 
Question:
How does a job owner view schedules and output?

Answer:
Schedules can be viewed by the web interface that shows the next start time of a job or of an order. Job output is gathered in log files that are accessible by the web interface for all job owners or by mails that can be configured to be sent by the Job Scheduler to specific job owners.

We do not support the concept of job owners in the web interface: this is used for administrative access, not for end users, therefore all jobs are shown to all allowed hosts. The presentation of schedules to end users should be part of an individual application. The Job Scheduler provides a XML request/response interface via TCP/IP that can be used to access this information:

sample request:
<show_state job="scheduler_cleanup_sos_files" what="all"/>
sample response:
<job job="scheduler_rotate_log" state="pending" title="Rotate 
  and compress logfiles"
     all_steps="0" all_tasks="0"
     log_file="c:/scheduler/logs/job.scheduler_rotate_log.log"
     order="no" tasks="1" in_period="yes" next_start_time="2005-10-18 01:00:00">
  <tasks count="0"/> 
  <queued_tasks length="0"/> 
  <log level="info" highest_level="debug3" last_info=""
       mail_on_error="yes"
       mail_on_warning="yes" smtp="localhost"
       mail_from="scheduler@sos-berlin.com"
       mail_to="info@sos-berlin.com"/> 
</job>
 

top of page
 
Ad-Hoc Changes to Job Streams
 
Question:
Can ad-hoc changes be set for established job streams?

Answer:
Jobs that are not part of a job stream (we call them: job chain) can be added and removed ad hoc; a job that is currently running will be unchanged until the end of its processing.

Jobs within a job chain can be changed without restarting the Job Scheduler. You can change any part of an order at any time without restarting the Job Scheduler. Supposed you have a job chain that processes database statements that are part of the payload parameters of an order; then you can change the contents of these sql statements ad hoc.

The possibility to apply changes without restart of the Job Scheduler is offered with the web interface for management of jobs and orders. Changes made directly to the configuration file scheduler.xml require the Job Scheduler to be restarted.

 

top of page
 
Trigger Error Conditions
 
Question:
Can a job call database procedures or a successor job for error handling?

Answer:
Within job chains an error state is assigend to a job and it is up to you to implement a job for error handling. Without specific job for error handling the Job Scheduler can be configured to send mails with an attached log file in case of errors.

The use of successor jobs in case of errors can be configured with:
    <job stop_on_error="no">
    ...
      <commands on_exit_code="error">
        <start_job job="my_error_handler"><params/></start_job>
      </commands>
    </job>
               
This configuration lets the job start a successor in case of an error that is signalled by an exit code that is not 0. Additionally this example causes the job to continue in case of errors (<job stop_on_error=...>), i.e. the normal behaviour to stop a job in case of errors does not apply.

 

top of page
 
Drag & Drop for Job Configuration
 
Question:
Is a desktop interface available to pull a file from desktop for inclusion in a job stream?

Answer:
No, the web interface does not support this.

 

top of page
 
Viewing Jobs
 
Question:
Can I allow a group of people to view a job I set up?

Answer:
The Job Scheduler web and XML interface via TCP/IP can be configured to restrict access to a number of hosts:


<security ignore_unknown_hosts = "yes">
  <allowed_host host = "192.11.0.0"  level = "info"/>
  <allowed_host host = "192.11.0.99" level = "none"/>
  <allowed_host host = "192.11.0.27" level = "all"/>
</security>
This configuration is translated as follows:
  • All hosts in the network 192.11.0.0 have read access to the scheduler interface, i.e. logs and schedules
  • The host 192.11.0.99 is not allowed any access
  • The host 192.11.0.27 is allowed full access, i.e. start jobs and orders, remove jobs etc.


"Viewing" means that the web interface shows this job and that XML responses are delivered to any application on the specified host that requests this information.

 

top of page
 
User-friendly drop-down list Environment
 
Question:
User-friendly drop-down list environment?

Answer:
We use drop-down listboxes in the web interface for job configurations wherever there is something to choose from. But honestly speaking this is an administrative interface for job management, not an end user tool with the usability of a Windows GUI.

A web demo is available for the Job Scheduler and the administration interface.

 

top of page
 
Built in Utilities for Routing Job Output
 
Question:
Built in utilities for routing job output?

Answer:
The answer is analog to what was said to Notification on Job Completion: all output of a job
  • to stdout
  • to stderr
  • created by API logging methods (info, warning, error, debug)
  • created by SQL errors and by usage of the Oracle Package dbms_output
  • to log files external to the Job Scheduler but for which a path was configured with the job

is added to the task log and sent by mail. The recipients (to, cc, bcc) can be configured centrally or per job. Log files with job output are stored as plain files in a log directory and optionally in the database (optionally gzipped).

 

top of page
 
Start Job by Notification
 
Question:
Is the Job Scheduler able to monitor directories (such as FTP upload directories) and execute a command or set of commands on each new or changed file?

Answer:
Yes. The API provides the method start_when_directory_changed (String directory, String pattern) that is used to specify the file names that match the pattern. Subdirectories are dto. monitored. Multiple calls to this method add the specified directories to the watch list.

Additionally you can configure any job to be launched automatically by directory notifications, e.g.:

<job name = "sample_job">
  <process file  = "/home/test/scheduler/jobs/sample_script.pl"
           param = "-f ${SCHEDULER_TASK_TRIGGER_FILES}"/>
  <start_when_directory_changed directory = "/tmp/input" regex = ".*"/>
</job>
In this example the paths of files that triggered the job start are handed by an environment variable to the job script parameter. Multiple paths are separated by ";".

 

top of page
 
Run Jobs as a Specific Userid
 
Question:
Is the Job Scheduler able to run jobs as a specific userid (not everything as one user or as root)?

Answer:
Yes with Unix, there are two possible solutions:

  • Use the executable setuid

    we provide the executable setuid for Unix (source code available) that is used to launch executable files on the local machine in a different account. No passwords for target accounts have to be provided. The program setuid should be configured with the following permissions:

    cd ~/scheduler/bin
    mkdir nobody
    chmod go-rwx nobody
    cp setuid nobody/setuid-nobody
    chown nobody nobody/setuid-nobody (has to be done by root)
    chmod u+s,a-r nobody/setuid-nobody (has to be done by root)


    Suppose the Job Scheduler is operated in the account "test" and has to launch executables in the account "nobody": with the above commands you will create a write-protected directory and copy of setuid for the account "nobody". The file setuid-nobody is executable for the account "test" but is owned by "nobody". With setuid-nobody the Job Scheduler can run any commands for the account "nobody" without giving a password for the target account. Therefore setuid-nobdy checks if the above permissions are set and otherwise terminates.

    For this solution you should ensure that the Job Scheduler's account and password are not publicly available to other users who are not authorized to run executables in the target account.

    A sample configuration in the file scheduler.xml for a command that is executed in the target account might look like this:
    
    <job name = "sample_setuid_job">
      <process file  = "$SCHEDULER_HOME/bin/nobody/setuid-nobody"
               param = "/home/test/scheduler/jobs/sample_script_notification.pl"/>
    </job>
    
  • Use secure shell

    Standalone scripts can be processed by ssh. You would have to:
    • set up the shh client and server
    • create a private/public key pair for the Job Scheduler on the client machine and publish your public key to the ssh server
    • run jobs via <process file="ssh"/> and give the ssh command line parameters in the attribute "param" of the <process> element

    ssh can be used to launch executables on your local and on remote machines. Alternatively you could install a Job Scheduler instance (=agent) on the remote machine which is less overhead if there is no ssh and pki infrastructure.

 

top of page
 
Control and Monitor Job Executions via Web Interface
 
Question:
Is the Job Scheduler able to control and monitor job executions via web interface?

Answer:
Yes, the Job Scheduler itself is a web server and can be adressed by http://host:port
Have a look at some slides of this interface. A management web interface is available for PHP, including the ability to monitor multiple Job Scheduler instances, create web based job configurations, manage job chains etc.

 

top of page
 
Import Job Specifications from Text Implementation
 
Question:
Can I import job specifications from text implementation, i.e. something that can be submitted to a versioning system,

Answer:
Yes! Job specifications are given in XML and are processed either from plain XML files or automatically loaded from a database (Oracle, SQL Server, DB2, MySQL, PostgreSQL, Firebird).

 

top of page
 
Run in Load Balanced or Fault Tolerance Mode
 
Question:
Can the Job Scheduler run in load balanced or fault tolerance mode?

Answer:
This feature is partially available: load balancing is available for order driven job implementations only, have a look at the section "order processing" in this flashmovie

Concerning fault tolerance we distinguish job errors and scheduler errors:
  • Job Errors: jobs may be configured to repeat automatically after errors in configurable intervals and number of trials.

  • Job Scheduler Errors: if the scheduler is operated with a database (which is not required) then automatic reconnects are available with a configurable number of trials. there are mechanisms to
    • Monitor errors, i.e. multiple Job Scheduler instances on the same or different servers send heartbeats to a Job Scheduler that is operated exclusively for monitoring;
    • Respawn a faulty Job Scheduler instance;
    • Do some "sanity checking" for disk space and memory usage by maintenance jobs.

    Fault tolerance is not available in the sense of automatic failover: if resources (disk space,
    database etc.) run short, then the Job Scheduler will finally shutdown. There is no such thing yet as a backup Job Scheduler instance starting automatically on a different server to continue jobs that were abandoned by the faulting Job Scheduler instance.

 

top of page
 
Run Job Agents on Multiple Machines
 
Question:
Can I run job agents on multiple machines: Solaris, Linux, Windows 2003 Server?

Answer:
Yes, these platform are supported (in addition we provide limited support for HP-UX):
job configurations can be loaded from disk files or from a central database which facilitates job deployment in a mixed environment.

 

top of page
 
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 the Job Scheduler API, e.g.
  • to write to the Job Scheduler logs which are visible in the web interface (and automatically mailed 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 the Job Scheduler which exposes the API objects and methods directly to the script. For the supported scripting languages the Job Scheduler 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) Sample Standalone Perl Script
The sample 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) Sample Perl Script using the Job Scheduler API
The file "sample_api_notification.pl" of the sample installation package is a more complete sample that demonstrates the usage of the Job Scheduler 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 sample 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 Job Scheduler.

 

top of page
 
Make the Job Scheduler work with MySQL 4.0.x
 
Question:
Does the Job Scheduler work with MySQL 4.0.x?

Answer:
Yes, if you run the database in ANSI mode. we do support a bunch of database systems, therefore we adhere quite strictly to ANSI compliant SQL statements.

Prior to MySQL 4.1.x you have to run the database server in ANSI mode either by an appropriate entry in my.cnf or by the parameter --ansi in the startup script of the database server. This setting will be valid for all databases that are operated by the MySQL server.

From MySQL 4.1.x on ANSI mode is available per client session and is automatically set by the Job Scheduler and the web interface, so you do not have to set it for the MySQL server.

 

top of page
 
Database Connections to MySQL get lost
 
Question:
I encounter the error:

Error connecting to [host]:[port]: SOS-JAVA-105 Java-Exception java.sql.SQLException("No operations allowed after connection closed."), methode=rollback []

Answer:
If the connection to your MySQL database was idle for some hours without any jobs running, then MySQL will close the connection without telling this to the client, i.e. the Job Scheduler. To change this behaviour you can change the value of the system variable wait timeout. This value assigns the maximum duration in seconds of non-interactive idle connections to the database.

Alternatively you could run a job like scheduler_dequeue_mail that is more frequently repeated; this job dequeues mails that have previously been stored in case of a failure of your mail server and creates a history record in the database even if no mails are to be sent.

 

top of page
 
JDBC Connection to SQL Server
 
Question:
I encounter the error:

SOS-JAVA-105 Java-Exception java.sql.SQLException("[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer] The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect.

Answer:
If you use an older version of the JDBC Driver, ( e.g. msbase.jar, mssqlserver.jar, msutil.jar ), then the URL for the JDBC connection in the configuration file ./config/factory.ini is different from the newer version sqljdbc.jar.

Older version:
db = jdbc -class=com.microsoft.jdbc.sqlserver.SQLServerDriver jdbc:microsoft:sqlserver://localhost:1433; selectMethod=Cursor;databaseName=scheduler -user=scheduler -password=scheduler

Newer version:
db = jdbc -class=com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc:sqlserver://localhost:1433; sendStringParametersAsUnicode=false;selectMethod=cursor;databaseName=scheduler -user=scheduler -password=scheduler

Please regard the different classnames and use of lowercase letters in the value "cursor".

 

top of page
 
eMails cannot be sent
 
Question:
No mails are sent by the Job Scheduler, why does this happen?

Answer:
The sender address must be a valid address for your mail server. Problems might occur with outgoing mails if the domain part of this address is not valid for the mail server. Adjust the sender address in the entry log_mail_from of the configuration file ./config/factory.ini.

 

top of page
 
Restart of the Job Scheduler
 
Question:
When does the Job Scheduler need a restart?

Answer:
After changes to one of the configuration files in the directory ./config have been made. After libraries in the directory ./lib have been replaced.

For normal operation a restart is not required, this applies as well for longer periods.

 

top of page
 
Licence Key for the Job Scheduler
 
Question:
The Job Scheduler asks for a licence key, isn't this software Open Source?

Answer:
Running the Job Scheduler on Unix with the binary file ./bin/scheduler or on Windows with the file ./bin/scheduler.exe will result in the error message:

SOS-1000 No licence key was found or licence key has expired. Please contact your systems administrator or Software- und Organisations-Service GmbH, Fax +49 (30) 861 33 35, Mail info@sos-berlin.com [Scheduler].

To start the Job Scheduler use the shell script ./bin/jobscheduler.sh (Unix) or ./bin/jobscheduler.cmd (Windows). The binary files are parametrised by the start script. One of the parameters (-sos.ini=...) in the start script addresses the licence file ./config/sos.ini,that contains a free licence key for the GPL version of the Job Scheduler.

There is no difference between GPL and commercially supported versions, in fact this is a technical licence key that helps us to identify commercial customers in case of support incidents.

 

top of page
 
Organizing secure file transfer with the Job Scheduler
 
Question:
We have an explicit need to invoke an ftp get file operation when a file becomes available on a remote server, assuming that:

  1. The remote server operating system is not supported by the Job Scheduler.

  2. We don't wish to rely on a program that uses the Job Scheduler API package running on the remote node to send us a notification (we can't maintain programs running on this remote node).

Is there any way to monitor a remote file directory or folder on the job schedule so that a notification is received on the main job scheduler to start the ftp get file program or script?

Answer:
  1. Proposed Solution: Signalling

    Should the remote host be responsible to signal the existence of a file ready for transfer, then concerning the remote host
    • don't be afraid of the Job Scheduler API, it might be as simple as this:

      telnet [scheduler_host] [scheduler_port]
      <start_job job="ftp_get_files"></params></start_job>

      This command is most likely available for the remote host and its simple: by means of a TCP stack you could send an XML command that tells the Job Scheduler what should be done, e.g. to start a job. Major parts of the API are available as XML commands that could be sent via TCP or UDP to the Job Scheduler. You do not have to use telnet as the ultimate TCP solution, it's just a sample that works at the command line.

    • use the Job Scheduler API without installation
      we deliver Java classes that could be used without a Job Scheduler being installed, e.g. on the command line like this:

      java -cp ./sos.scheduler.jar:./sos.util.jar sos.scheduler.SOSSchedulerCommand [scheduler_host] [scheduler_port] [xml command]

      Java is available for most operating systems, therefore the remote host could use this command line to send any XML command to the Job Scheduler without the need to have a Job Scheduler being installed on the remote host. A standard JRE 1.4.2++ and the above .jar archives would be sufficient for the remote host.

    • use an alternative TCP/UDP stack
      You could use any programming/scripting language that supports TCP or UDP to send XML commands.

    The above cases do not assume that you have to maintain the resp. scripts/programs on the remote host as standard operating system utilities could be used for this. We recommend to use UDP in the above solutions as this protocol is non-blocking, i.e. the remote host will not suffer (and have to recover) from errors due to network downtimes. Therefore use of signalling should be optional in the communication between remote host and Job Scheduler to speed up processing but is no replacement for polling.

  2. Proposed solution: polling

    we recommend this solution as it is save and easy to implement to check if a file exists on a remote host:
    • Check via FTP
      See the standard jobs in the chapter for FTP processing at Job Scheduler Standard Jobs and the job documentation in Job Scheduler FTP Receive. The existing code could be adapted to return distinct exit codes that signal if files are available or absent in a remote directory.

    • Check via ssh
      This solution requires a shell script or operating system command on the remote host that is launched via ssh by a job in order to check if a file is ready to be transferred. The script/command could be implemented to return a distinct exit code which signals that files are ready for transfer.

      A pseudo configuration for scheduler.xml could be:
      <job>
        <process file="ssh" param="-l [user]@[host] [script_or_command]">
          <!-- restart this job if an error occurs, e.g. file not present, 
               server unavailable etc. -->
          <delay_after_error error_count="1" delay="60"/> 
          <!-- repeat this job every 60s after the first error occurred -->
          <delay_after_error error_count="10" delay="600"/> 
          <!-- repeat this job every 600s after the 10th error occurred -->
          <delay_after_error error_count="50" delay="stop"/> 
          <!-- stop this job after 50 subsequent errors -->
          <!-- in case of files found: exit code=0, let's fetch the files -->
          <commands on_exit_code="success">
          <start_job job="ftp_get_files"><params/></start_job></commands>
          <!-- in case of absence of files: exit code=1 -->
          <!-- let's ignore this return code -->
          <commands on_exit_code="1"/>
          <!-- other exit codes are automatically handled as errors, 
               otherwise you could start individual jobs to handle errors -->
          <!-- <commands on_exit_code="error">...</commands> -->
        </process>
      </job>
      
      Starting successor jobs based on exit codes is not restricted to ssh or the use of <process file=""/>, you could configure any job to start arbitrary successor jobs and orders from Job Scheduler release 1.2.7 on.

  3. Concurrency Issues

    A simple way to avoid concurrency would be to have the client put files with a name as filename~ and rename them to filename. This would make the files appear atomically.

    More sophisticated solutions are needed in the following cases:
    • What should happen if one input file cannot be fetched for a longer period and subsequent files are provided by the remote host?
    • How should multiple input files be handled that are to be processed in a single transaction by the client, e.g. for dbms import?

    We implemented commercial solutions for these issues based on traffic light rules. If this should be of any interest to you then please contact us.

 

top of page
 
How to implement Jobs with Perl?
 
Question:
Where can I get the Perl libraries for the Job Schedule API? There is a package main, do I get that with the Job Scheduler download or do I have to go to CPAN?

Answer:
It depends on the operating system:
  • for Windows we do not distribute a library but use the scripting libraries from an existing ActiveState Perl implementation, see http://www.activestate.com.
  • for Unix the library libsosperlscript.so should have been copied to the lib directory by the installer. Moreover the library libperl.so is given in this directory: this library could be replaced from your Perl installation, it is the subprogram interface that must fit to the threading options that Perl was compiled with. The version that is provided by the setup is for a multithreaded Perl 5.8.0.

Keep in mind that:
  • you could use
    <job><process file="my_script.pl"/></job>
    to use Perl as from the command line (my_script.pl must be executable). This works with all versions of Perl, but no API methods of the Job Scheduler can be used.
  • you would use
    <job><script language="perlscript"><include file="my_api_script.pl"/></job>
    for a Perl script that makes use of the Job Scheduler API and requires the above libraries for Unix.

The API documentation is available:

There is no such thing as a Job Scheduler package for Perl as the Job Scheduler exposes its objects and methods directly, just use

  # to make the object variables available ...
  use vars qw ($spooler $spooler_log $spooler_job $spooler_task);
  
  # ... then use the objects and methods, e.g to access a job parameter
  $spooler_task->params->value("request_stylesheet")
Some more complete examples of Perl jobs are given in the solutions section of this site, see
Web Services for Executable Files

The given examples are mainly interesting as we provided job implementations for Perl, Java and Javascript: even if you do not intend to implement Web Services the source code and job documentations are useful to see how the API works equally for all languages.

 

top of page
 
What is the concept of "job chains and order processing"?
 
Question:
I set up 2 jobs as job_chain_nodes in a chain based on scheduler_sample_perlscript.xml.
I then kicked off the first job that does a FTP get and gets me the files. My problem is the second job does not start after the first ends. Could you let me know what the problem could be ?

Answer:
There is a misunderstanding in what you said by "I then kick off the first job": if you are organizing jobs in a job chain, then you do not start any of the jobs manually, but would create an order that makes the jobs start automatically. Job chains are driven by orders, i.e. you would create multiple orders simultaneously or with a given run time or repeat interval.

Have a look at the single take "order processing" in our presentation (flashmovie)

Sample for a Job Chain and an Order
  <spooler>
    <config>
      <jobs>
      ...       
      </jobs>
      <job_chains>
        <job_chain name="TestGetandPut">
        <job_chain_node state="1"     
            job="TestGet"     
            next_state="100"     
            error_state="999"/> 
        <job_chain_node state="100" 
            job="GetPut"     
            next_state="200"     
            error_state="999"/> 
        <job_chain_node state="200" /> 
        <job_chain_node state="999" />
      </job_chain>
       ...      
      </job_chains>
      <commands>
        <!-- here you add an order for your job chain>
        <add_order job_chain=" TestGetandPut" 
        title="sample order" replace="yes">
          <params/>
            <!-- sample run time: repeat the execution of this order 
                every day at the given hour -->
            <!-- without run time specification an order is fired just 
                once and will not be repeated -->    
            <run_time><period single_start="23:36"/></run_time>
        </add_order>
      </commands>
    </config>
  </spooler>
When an order enters the job chain it will be processed by the job that is assigned the first state ("1"), i.e. TestGet. If processing was successful then the order is assigned the state of the next job node in the chain ("100").

The order is then processed by the job TestPut in the second position of the chain which would result in an end state "200", i.e. the order leaves the job chain. If an error had occurred, e.g. in the job TestGet, then the order would have been assigned the error state "999". In the configuration sample this is an end state, so the order leaves the job chain.

In addition to this configuration sample you could use the Job Scheduler API in your jobs to set the state of an order depending on your business logic: if the processing in a job chain should not be linear but the choice of the successor job should depend e.g. on an execution result or any other event in your job, then you could use the method order.set_state("300") for the targeted successor job.

This concept may sound astonishing but think about the advantages, just to name a few:
  • Orders can be processed simultaneously, the jobs can be configured (e.g. by <job tasks="3"/>) to run in parallel tasks to process these orders.
  • Orders can have parameters, i.e you use the same job implementation that is parameterized at execution time by the respective order, e.g. the order could contain the settings required for ftp connections.
  • Orders could have a payload, i.e. arbitrary xml element structures that are accessible by every job in a job chain and can thus be used to pass execution results from one job in a job chain to the next one.
  • Orders can be set back, i.e. could change their position in the job chain to be repeated starting with a distinct job chain node.
  • Every order has its own log file that contains the information of all jobs that have been passed in the job chain, whereas subsequent tasks would create individual task logs.

You would achieve a similar effect using successor jobs: two jobs are executed in sequence, but you will receive two distinct log files.

 

top of page
 
Could you show me a simple example of a job chain?
 
Question:
Does every job chain need an order to be triggered? Is there some simple example for the use of job chains and orders?

Answer:
Processing of a job chain is always triggered by an order. Therefore three peaces are put together: jobs, a job chain and an order.

  • Let's look at the job implementation. Any job could be used for a job chain, however the attribute order="yes" is required:

      <spooler>
        <config>
          <jobs>
            <job name="command_1" title="sample_command" order="yes">
              <script language="shell">
                <![CDATA[
                 C:\Programme\Samples\Scripts\command_sample_1.cmd
                ]]>
              <script>
            </job>
    
            <job name="command_2" title="sample_command" order="yes">
              <script language="shell">
                <![CDATA[
                 C:\Programme\Samples\Scripts\command_sample_2.cmd
                ]]>
              <script>
            </job>
          </jobs>
        </config>
      </spooler>
    
  • Next you need a job chain that assigns nodes and states to these jobs:

      <spooler>
        <config>
          <job_chains>
            <job_chain name="command_sequence">
              <job_chain_node state="first"     
                  job="command_1"     
                  next_state="second"     
                  error_state="error"/> 
              <job_chain_node state="second" 
                  job="command_2"     
                  next_state="success"     
                  error_state="error"/> 
              <job_chain_node state="success"/> 
              <job_chain_node state="errror"/>
            </job_chain>
          </job_chains>
        </config>
      </spooler>
    
    This sample assigns the above job command_1 the first node in the chain and command_2 the second node that will be executed if the first node were successfully completed. The chaining is organized by the next_state attribute that identifies the state of the next job node in a chain and respectively the error_state attribute that identifies the node that should be executed in case of error. Job nodes for final states could be empty as for success and error, moreover you could create job implementations for individual error handling.

  • Last but not least you need an order that triggers the execution of the job chain:

      <spooler>
        <config>
          <commands>
            <add_order job_chain="command_sequence" 
              title="sample command sequence" replace="yes">
              <params/>
                <!-- sample run time: repeat the execution of this order 
                     every day at the given hour -->
                <run_time><period single_start="23:36"/></run_time>
            </add_order>
          </commands>
        </config>
      </spooler>
    
    This order is used for three purposes:
    • Trigger the execution of the job chain:
      You would not start a job chain by starting the first job node, but by starting the order. The built-in HTML interface of the Job Scheduler offers the respective operations for orders. Multiple orders could cause the parallel execution of jobs in a job chain. The Job Scheduler would then dynamically allocate tasks in parallel to these jobs.
    • Add parameters to the jobs within the job chain:
      Parameters from orders are added with precedence to the parameters of a job configuration (<job><params><param name="sample_name" value="sample_value"></params></job>).
    • Specify the run time for automated execution:
      Any periods for repeated execution could be set.

You could ask, why an order is required if parameters and run time periods could equally be added to jobs? The answer is: reusability of jobs and job chains. You could use multiple orders for the same job chain with different parameter sets.

 

top of page
 
Restoring enqueued orders and jobs in job chains
 
Question:
We have a job chain of jobs - 1,2,3. Then I kill the scheduler after Job1 is complete but while Job2 is running and then bring the scheduler back up. If we re-start the job stream will it start at Job2?

Answer:
Yes, the order will be enqueued with a state for Job2. This applies to both orders and jobs:

1)  Persistence of Enqueued Orders
If an order is enqueued (either for one time processing without any run time or with a run time for repeated processing) then the Job Scheduler stores this order in the database (in the table SCHEDULER_ORDERS) should a database be used. This behaviour is independent from use of "Managed Jobs" and applies for all orders.

Changes to the order state that reflect the proceeding of the order in the job chain to the next job node are equally updated in the database. To be transactionally correct the order state is updated after
  • The method spooler_process() is left for jobs that make use of the API via <script/>
  • An executable file has been terminated that was started via <process/>

If the Job Scheduler is killed while an order is processed then the order with it's current state, i.e. the input level of the current job node, will be restored from the database on the next start of the Job Scheduler.

2)  Persistence of Enqueued Jobs
This is handled in the following way:
  • Tasks that are running and are killed due to killing the Job Scheduler main task are not restarted on scheduler startup (as the Job Scheduler cannot decide if it's decent to re-execute this job regarding run times and corresponding begin and end time slots etc.).

  • Should a task be enqueued for a future date, e.g. with
    <start_job job="..." at="now+3600"/><params/></start_job>
    or the respective API methods then this task's start time is reflected in the database (in the table SCHEDULER_TASKS). For orders and jobs the Job Scheduler will read the respective tables on startup and enqueue the respective orders and task to the given start time.


 

top of page
 
How can we configure a holiday setting for the Job Scheduler?
 
Question:
We will be setting up jobs to be run everyday. We also need a mechanism to build in a holiday schedule for the entire year that is not lost on a weekend restart. So I need to configure the Job Scheduler not to run on say 10 specific days in a year. What is the best way to do this?

Answer:
Holidays can be configured at a global level for all jobs and per job. The resulting holiday dates of both configuration levels are applied. They are not lost on restart as they are part of the configuration file scheduler.xml or the respective run times that are configured in the web interface and stored in a database. Configuring holidays is supported by the visual Job Configuration Editor.

1)  Holidays for all jobs
  <config>
      <holidays>
          <holiday date="2006-12-25"/>
          ...
          <holiday date="2006-12-26"/>
      </holidays>
      <jobs/>
      <job_chains/>
  </config>
2)  Holidays for a specific job
  <job>
    <run_time let_run="no">
        <period single_start = "08:00"/>
        <holidays>
            <holiday date="2006-06-19"/>
            ...
            <holiday date="2006-07-19"/>
        </holidays>
    </run_time>
  </job>              
 

top of page
 
The Master and Slave relationship of the Job Scheduler
 
Question:
Could you explain how the master - slave relationship works in a little more detail?. If I have one master and 5 slaves can I view and update all five slaves from the master Job Scheduler ?

Answer:
There are two concepts: a loose coupling of master/slave Job Schedulers that are monitored by the master and the use of global configurations for multiple Job Schedulers that are stored in a central database. Both concepts can be used in combination.

1)  Loosely coupled Job Schedulers
The slave Job Schedulers send heartbeats, i.e. a TCP signal once per minute, to the master Job Scheduler. This could be configured in scheduler.xml by
  <config main_scheduler        = "remotehost:4444">
  ...
  </config>
For any of the slave Job Schedulers, the signal is sent to the respective host:port. The master Job Scheduler registers the signal and keeps a list of slave Job Schedulers. If the signal is not repeated in time then a slave Job Scheduler is considered as "disconnected" but could reconnect any time. The information about registered slave Job Schedulers is available in the web interface, the API or xml commands (<show_state what="remote_schedulers"/>

In addition to this we provide a standard job in the distribution that is executed in the master Job Scheduler and checks if the slaves are alive. You should use this job, if you run multiple Job Schedulers and want to receive warnings by mail if one of them is not registered, not connected or has otherwise terminated.

For details have a look at the job documentation for: Job Scheduler Check Slaves
For a full list of standard jobs and source code see: Solutions / Standard Jobs


2)  Use of the installation package "Managed Jobs"
In this case - besides the configuration in scheduler.xml - configurations for jobs, job chains and orders are stored in a database.
These configurations can be assigned to one or multiple Job Schedulers that are distinguished by their ID, that is specified in scheduler.xml by <config spooler_id = "id1"/>

If you assign multiple Job Schedulers the same ID then all of them will run the configurations that have have allocated this ID in the web interface of the "Managed Jobs" package. To make multiple Job Schedulers read the central configuration the "Managed Jobs" package provides an additional configuration file scheduler_managed.xml which contains a start script that reads the configuration from the database, e.g.

  <config>
      <script language = "java"
             java_class = "sos.scheduler.managed.JobSchedulerManagedStarter"/>
      <jobs/>
      <job_chains/>
  </config>
More details are given in the help for Job Scheduler Managed Jobs

 

top of page
 
How can we setup our log files to be written in a database?
 
Question:
How can we setup our log files to be written in a database ?

Answer:
This is automatically done by the Job Scheduler, if you configure a database connection in ./config/factory.ini The Job Scheduler creates protocols for tasks and orders, have a look at the detailed explanation. of log files.

To name a few settings in ./config/factory.ini:
  ;                         enable job history, if set to yes the 
  ;                         scheduler keeps a job history in 
  ;                         csv files or database tables
  history                 = yes
  ;                         store job protocol for task history 
  ;                         (yes|no|gzip, default: no)
  history_with_log        = gzip
  ;                         store job protocol for order history 
  ;                         (yes|no|gzip, default: no)
  order_history_with_log  = gzip
  ;                         store protocol for scheduler history 
  ;                        (yes|no|gzip, default: no)
  history_archive         = gzip
This examples specifies protocols to be stored in blob columns of the database in a gzip format, for a complete list of settings see factory.ini. The Job Scheduler web interface allows to search the job history and to display the content of the logs. You could remove the log files from disk and would keep the logs in the database.    

We provide a set of standard jobs concerning logging and cleanup that rotate logs, remove debug entries from logs in the database and gzip log files on disk. ... read more


 

top of page
 
When to use the open source and the closed source licence
 
Question:
When should i use the open source and the closed source licence?

Answer:
You can use the open source licence at any time without charge, but you underly the restrictions of the GPL, e.g. if you plan to modify or ship the Job Scheduler to third parties. The closed source licence is suitable if any of the following cases applies:

  • If you bundle the Job Scheduler with your application for shipment to third parties
  • If you need an indemnity agreement that protects you and your company from third party claims
  • If you wish to have a limited warranty for two years which includes bugfixing at no additional charge; you could run the Job Scheduler without any support option and safely rely on bugs being fixed during the warranty period.
  • If you choose one of the offered support options and the calculated pricing is favourable.


 

top of page
 
Handling of support options for multiple Job Scheduler installations
 
Question:
Do i have to buy support options for every Job Scheduler installation?

Answer:
No, you don't - if you run multiple Job Schedulers then you could choose which installations should be supported. we agree, if you handle your support options as in the following example:

  • Buy support options for three servers: one for Linux, one for Solaris, one for Windows. Alternatively buy support options for the respective operating systems, e.g. Win2000, Win2003, WinXP
  • You will receive three support licence keys that are restricted to three Job Scheduler installations
  • You operate the Job Scheduler for all other servers without support option
  • When opening a support request for one of these platforms/ operating systems then the respective support licence key should be submitted to identify the underlying support option (we do not require to identify server, cpu or details that you won't submit voluntarily)
  • If you want to submit a support request for a server that is not covered by one of the above support licence keys then you would have to reproduce the problem for one of the supported servers

The proposed handling of support options is targeted at a scenario where e.g. you run approximately identical test and production systems or run multiple servers with analogous configurations (operating systems, databases) and will easily be able to reproduce problems in the supported environments.

Alternatively, If you wish to have a support option for every server that you operate the Job Scheduler for, then we would offer you volume based support options.

 

top of page
 
Why does the log file show on GUI with delay?
 
Question:
If I click on the menu button and select show log ...sometimes the GUI (scheduler) screen comes up totally blank (almost as if there is no log). After a while the log finally appears on the GUI. Can you point out why there might be a delay?

Answer:
Check if the number of process classes in your scheduler.xml is sufficient(defaults to 10), e.g.
        <process_classes>
            <process_class max_processes="20"/>
            <process_class name="many_processes" max_processes="30"/>
            ...
        </process_classes>
A set of standard processes runs in the default process class (the one without the attribute name=). The handling of TCP requests (which is what y