We assume that there is a crontab with the following content:

 */30 * * * *  /path_to_file/file.sh    >> /path_to_file/file.log    2>&1

We assume that this file is located in /tmp/my_crontab.

The migration has two steps:

Step 1: Calling ./bin/cronconverter.sh

In the first step you call ./bin/cronconverter.sh.
This creates an xml file with all jobs.

This script is used as follows:

 usage: cronconverter [-changeuser <command>] [-createJobChains
       <true|false>] [-createMock <true|false>] -crontab <file> [-systab <0|1>]
       -target <file> [-v <level>]
 -changeuser <command>           change user command for -systab=1. 'su'
                                 or 'sudo' or define your own command using $SCHEDULER_CRONTAB_USER.
 -createJobChains <true|false>   set to true if you want to create
                                 jobChains and jobs
 -createMock <true|false>        set to true if script has to be mok'ed
 -crontab <file>                 crontab file
 -systab <0|1>                   set to 1 if source is the system crontab
                                 (with user field)
 -target <file>                  xml configuration file
 -v <level>                      loglevel [0=info] [1=debug1]...[9=debug]

You can create Standalone-Jobs or Order-Jobs including a Job Chain and an Order for each cron job.
Please create a target folder for the conversion (e.g. ./cron) and call the converter.

1. Standalone-Jobs

./bin/cronconverter.sh -crontab /tmp/my_crontab -target cron/cronconvert_result.xml

2. Order Jobs with Job Chain and Order (recommended)

./bin/cronconverter.sh -crontab /tmp/my_crontab -createJobChains true -target cron/cronconvert_result.xml

This creates the file cron/cronconvert_result.xml that contains all Jobs, Job Chains and Orders for further transformation (see step 2).

Step 2: Calling ./config/xml2live.xsl

java -jar lib/saxon9he.jar -s:"cron/cronconvert_result.xml" -xsl:"config/xml2live.xsl" sos.destination="cron/live"

This call creates a directory ./cron/live/GlobalCollect/ that contains the JobScheduler objects (Jobs, Job Chains, Orders).
The folder has subdirectories corresponding to the paths of the cron jobs.
In our example you should get

  • ./cron/live/GlobalCollect/path_to_file/file.sh.job.xml
    when you have called the cronconverter without -createJobChains or otherwise
  • ./cron/live/GlobalCollect/path_to_file/file.sh.job.xml
  • ./cron/live/GlobalCollect/path_to_file/file.sh.job_chain.xml
  • ./cron/live/GlobalCollect/path_to_file/file.sh,file_sh.order.xml

with the following content:

./cron/live/GlobalCollect/path_to_file/file.sh.job.xml (Standalone-Job)

<?xml version="1.0" encoding="iso-8859-1"?>
<job timeout="600" title="Cron Job /path_to_file/file.sh    >> /path_to_file/file.log    2>&1">
  <extensions>
    <extension xmlns="www.sos-berlin.com/schema/joe">
      <generator date="2013-02-21 11:46:18" name="CronConverter" vendor="www.sos-berlin.com">
        <docu>*/30 * * * *  /path_to_file/file.sh    >> /path_to_file/file.log    2>&1</docu>
      </generator>
      <comment/>
    </extension>
  </extensions>
  <script language="shell"><![CDATA[
echo created by CronConverter, at 2013-02-21 11:46:18
/path_to_file/file.sh    >> /path_to_file/file.log    2>&1
  ]]></script>
  <run_time>
    <period repeat="00:30"/>
  </run_time>
</job>

 

./cron/live/GlobalCollect/path_to_file/file.sh.job.xml (Order Job)

<?xml version="1.0" encoding="iso-8859-1"?>
<job order="yes" timeout="600" title="Cron Job /path_to_file/file.sh    >> /path_to_file/file.log    2>&1">
  <extensions>
    <extension xmlns="www.sos-berlin.com/schema/joe">
      <generator date="2013-02-21 11:46:18" name="CronConverter" vendor="www.sos-berlin.com">
        <docu>*/30 * * * *  /path_to_file/file.sh    >> /path_to_file/file.log    2>&1</docu>
      </generator>
      <comment/>
    </extension>
  </extensions>
  <script language="shell"><![CDATA[
echo created by CronConverter, at 2013-02-21 11:46:18
/path_to_file/file.sh    >> /path_to_file/file.log    2>&1
  ]]></script>
</job>

 

./cron/live/GlobalCollect/path_to_file/file.sh.job_chain.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<job_chain>
  <extensions>
    <extension xmlns="www.sos-berlin.com/schema/joe">
      <generator date="2013-02-21 11:46:18" name="CronConverter" vendor="www.sos-berlin.com">
         <docu>*/30 * * * *  /path_to_file/file.sh    >> /path_to_file/file.log    2>&1</docu>
      </generator>
      <comment/>
    </extension>
  </extensions>
    <job_chain_node error_state="error" job="file.sh" next_state="success" state="100"/>
    <job_chain_node state="success"/>
    <job_chain_node state="error"/>
 </job_chain>

 

./cron/live/GlobalCollect/path_to_file/file.sh,file_sh.order.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<order title="GlobalCollect/path_to_file/file.sh">
  <extensions>
    <extension xmlns="www.sos-berlin.com/schema/joe">
      <generator date="2013-02-21 11:46:18" name="CronConverter" vendor="www.sos-berlin.com">
        <docu>*/30 * * * *  /path_to_file/file.sh    >> /path_to_file/file.log    2>&1</docu>
      </generator>
      <comment/>
    </extension>
  </extensions>
  <run_time>
    <period repeat="00:30"/>
  </run_time>
</order>

Now you can copy the folder content of ./cron/live/GlobalCollect/* to ./config/live/.

Open JOC and you see the new objects.