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

Compare with Current View Page History

Version 1 Next »

We assume that we have 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 stored in /tmp/my_crontab.

The Migration has two steps:

1. Calling ./bin/cronconverter.sh

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

This script has the following usage:

 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 inclusive 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 create the file cron/cronconvert_result.xml which contains all Jobs, Job Chains and Orders for further transformation (see step 2).

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 create a directory ./cron/live/GlobalCollect/ which contains the JobScheduler objects (Jobs, Job Chains, Orders).
The folder has subdirectories corresponding to the paths of the cron jobs.
In our example you get

  • ./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

 <?xml version="1.0" encoding="iso-8859-1"?>
 <job order="yes" timeout="600"
      title="Cron Job /path_to_file/file.sh    &amp;gt;&amp;gt; /path_to_file/file.log    2&amp;gt;&amp;amp;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    &amp;gt;&amp;gt; /path_to_file/file.log    2&amp;gt;&amp;amp;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    &amp;gt;&amp;gt; /path_to_file/file.log    2&amp;gt;&amp;amp;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    &amp;gt;&amp;gt; /path_to_file/file.log    2&amp;gt;&amp;amp;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.

  • No labels