Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
We assume that we have there is a crontab with the following content:
Code Block |
---|
*/30 * * * * /path_to_file/file.sh >> /path_to_file/file.log 2>&1
|
We assume that this file is stored located in /tmp/my_crontab.
The Migration migration has two steps:
Step 1
...
: Calling ./bin/cronconverter.sh
In the first step you call ./bin/cronconverter.sh.
This create one creates an xml file with all jobs.
This script has the following usageis used as follows:
Code Block |
---|
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 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
Code Block |
---|
./bin/cronconverter.sh -crontab /tmp/my_crontab -target cron/cronconvert_result.xml
|
2. Order - Jobs with Job Chain and Order (recommended)
Code Block |
---|
./bin/cronconverter.sh -crontab /tmp/my_crontab -createJobChains true -target cron/cronconvert_result.xml
|
This create creates the file cron/cronconvert_result.xml which that contains all Jobs, Job Chains and Orders for further transformation (see step 2).
Step 2
...
: Calling ./config/xml2live.xsl
Code Block |
---|
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/ which 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
...
./cron/live/GlobalCollect/path_to_file/file.sh.job.xml (Standalone-Job)
Code Block |
---|
<?xml version="1.0" encoding="iso-8859-1"?> <job timeout="600" title="Cron Job /path_to_file/file.sh &gt;&gt;>> /path_to_file/file.log 2&gt;&amp;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 &gt;&gt;>> /path_to_file/file.log 2&gt;&amp;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)
Code Block |
---|
<?xml version="1.0" encoding="iso-8859-1"?> <job order="yes" timeout="600" title="Cron Job /path_to_file/file.sh &gt;&gt;>> /path_to_file/file.log 2&gt;&amp;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 &gt;&gt;>> /path_to_file/file.log 2&gt;&amp;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
Code Block |
---|
<?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 &gt;&gt;>> /path_to_file/file.log 2&gt;&amp;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
Code Block |
---|
<?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 &gt;&gt;>> /path_to_file/file.log 2&gt;&amp;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.