OPEN SOURCE - Job Scheduler - Quickstart

Job Scheduler
 
 
Job Scheduler - Quickstart
 

You have installed the Job Scheduler and now you want to know what to do next?

The following samples provide a quickstart how to use Job Scheduler. If you want to use all the Job Scheduler features, then you should refer to the documentation section.

All samples are created from scratch as XML files using any editor of your choice. An introduction to the Job Configuration Editor that saves the hazzle of typing XML and that provides more samples is available in the Quickstart for Job Configuration.

Note that in these sample jobs relative links are used from the Job Scheduler installation directory. This directory is the working directory for your jobs.

The Managed Jobs package, that you might have selected during setup is not used for these jobs, but rather hot folders, i.e. you can paste the samples jobs into files in the ./config/live directory.

Please stick to the naming scheme job_name.job.xml, e.g. if a job is created with the name my_shell_script then its file name would be ./config/live/my_shell_script.job.xml. Whenever you add, delete or change a job definition it will be immediately applied by Job Scheduler that monitors your hot folders.

If Job Scheduler is running on localhost and port 4444, please use the following URLs:

  • http://localhost:4444
    to control jobs use the job context menu with operations to start and stop jobs

  • http://localhost:4444/doc/en/index.xml
    to access the reference documentation, alternatively open the file
    ./config/html/doc/en/index.xml

 
 
 
 
Overview of the samples:
 
Presentations using the Managed Jobs package:
 
 
 
top of page
 
 
Sample 1: Time Controlled Execution of Shell Scripts
By this sample you can automatically start the job my_shell_script every 30 minutes on weekdays within the period 9am-12am. Furthermore you can start the job manually in the period 8am-8pm. The job executes the./jobs/my_shell_script.sh shell script. It is possible to combine time control with directory monitoring (see sample 2 ).
 
Paste this sample into a file ./config/live/my_shell_script.job.xml:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<job>
   <script language="shell">
     <include file="jobs/my_shell_script.sh"/>
     <!-- for Windows use "jobs\my_shell_script.cmd" -->
   </script>
   <run_time begin = "08:00"
               end = "20:00">
     <weekdays>
       <day day="1">
         <period begin = "09:00" end = "12:00" repeat = "1800"/>       
       </day>
       <day day="2">
         <period begin = "09:00" end = "12:00" repeat = "1800"/>       
       </day>
       <day day="3">
         <period begin = "09:00" end = "12:00" repeat = "1800"/>       
       </day>
       <day day="4">
         <period begin = "09:00" end = "12:00" repeat = "1800"/>       
       </day>
       <day day="5">
         <period begin = "09:00" end = "12:00" repeat = "1800"/>       
       </day>
     </weekdays>
   </run_time>
</job>
                  
 
 
 
top of page
 
 
Sample 2: Execution of a Shell Script per Directory Monitoring
This sample shows how to monitor a directory named ./notification_dir. As soon as a new file with the extension .txt is added or removed from this directory, the Job Scheduler automatically starts the my_shell_script job. In addition manual job starts are also possible. The job executes the ./jobs/my_shell_script.sh shell script. You could combine the directory monitoring with time control (see sample 1).
 
Create a directory ./notification_dir and change the content of the file ./config/live/my_shell_script.job.xml like this:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<job>
   <script language="shell">
     <include file="jobs/my_shell_script.sh"/>
     <!-- for Windows use "jobs\my_shell_script.cmd" -->
   </script>
   <start_when_directory_changed directory = "notification_dir"
                                     regex = "\.txt$"/>
   <run_time/>
</job>
                  
 
 
 
top of page
 
 
Sample 3: Execution of a PHP Script
This sample allows you to start the my_php_script job manually. It executes the PHP command line interface with a PHP script of your choice. The job content is given in a CDATA element, therefore you do not have to create a shell script or command file. For more information about time control and directory monitoring see sample 1 and sample 2.
 
Adjust the path to your PHP interpreter and to the respective PHP script and paste this sample into a file ./config/live/my_php_script.job.xml:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<job>
   <script language="shell"><![CDATA[ 
     /usr/src/php-4.3.3/sapi/cli/php -f jobs/my_php_script.php
   ]]></script>
   <!-- for Windows use "c:\php\cli\php.exe" -->
   <run_time/>
</job>
                  
 
 
 
top of page
 
 
Sample 4: Executing Programs
In this sample script two jobs are used to restart the MySQL Windows Service at 3am. The first job service_stop stops the service and the second job service_start starts it. These jobs are executed using the Windows net.exe application. This program can be found in the Windows system32 subdirectory. To specify the program path you can use the %windir% environment variable.
 
Paste this sample into a file ./config/live/service_stop.job.xml:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe stop MySQL
   ]]></script>
   <run_time>
     <period single_start = "03:00"/>
   </run_time>
</job>
                  
Paste this sample into a file ./config/live/service_start.job.xml:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe start MySQL
   ]]></script>
   <run_time>
     <period single_start = "03:02"/>
   </run_time>
</job>
                  
Instead of chaining both jobs by a time interval of some minutes which might or might not apply, an even better solution for the restart of a Windows Service would be to start the second job after the first job should this complete successfully. You could configure the second job as a successor to the first job.
 
Paste this sample into a file ./config/live/service_restart.job.xml:
 
<?xml version="1.0" encoding="iso-8859-1"?>
<job>
   <script language="shell"><![CDATA[ 
     %windir%\system32\net.exe stop MySQL
   ]]></script>
   <run_time>
     <period single_start = "03:00"/>
   </run_time>
   <commands on_exit_code="success">
     <start_job job="service_start"/>
   </commands>
</job>
                  
 
 
 
top of page
 
  For more detailed samples please refer to the following sections:  
 
  Office Automation - Document Delivery - Job Scheduling - Systems Integration - Output Management - Enterprise Application Integration - Connectivity