Unfortunately there is no tool to launch a Scheduler Task from the command-line, which is required at many times when you need to run OIM scheduler from schedulers outside OIM or command line.
I wrote this utility to run scheduler from cmd.This Utility launches a Scheduler Task from the command-line.First create a directory "RunSchedulerTask" and then copy these files (source code below)· "RunSchedulerTask.java" · "build.xml" To run, simply open a command-line prompt, change directory to RunSchedulerTask, and run ant: ${xl.home}\ant\bin\ant.bat run -Dxl.home="${xl.home}" -Dargs="
Source code for RunSchedulerTask.java
import Thor.API.Security.LoginHandler.LoginSession;import Thor.API.Security.XLClientSecurityAssociation;import Thor.API.tcUtilityFactory;import com.thortech.util.logging.Logger;import com.thortech.xl.client.dataobj.tcDataBaseClient;import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;import com.thortech.xl.util.config.ConfigurationClient;import java.io.*;import java.util.Properties;
/* * RunSchedulerTask * * Runs an Xellerate Scheduler task from the command-line. * @author Akshat Agarwal */public class RunSchedulerTask{ /* * arg[0] : recon class name. Class must derived from SchedulerBaseTask * arg[1] : username * arg[2] : password * arg[3] : Aktask.properties is the properties file containing the Scheduler Task attributes */ public static void main(String args[]) { if (args.length < sctask =" (SchedulerBaseTask)" prop =" ConfigurationClient.getComplexSettingByPath(" tcutilityfactory =" new" attributes =" new"> 3) { attributes.load( new FileInputStream( new File(args[3]) )); scTask.setTaskAttributeMap(attributes); } // Get a database handle LoginSession loginsession = tcutilityfactory.getLoginSession(); XLClientSecurityAssociation.setGlobalLoginSession(loginsession);
tcDataBaseClient dbClient = new tcDataBaseClient(); //String s = dbClient.getDatabaseName(); scTask.setDataBase(dbClient);
// Running the Scheduler Base task scTask.runAsThread(); boolean success = scTask.isSuccess(); if (!success) { System.out.println("Scheduler Failed to Run"); String message = scTask.getStatus(); System.out.println("Status: " + message); Exception ex = scTask.getResult(); } } catch (Exception ex) { ex.printStackTrace(); } System.exit(0); }}
BUILD.xml file
-----
task.properties
Day Max=UNLIMITED
Task Max=UNLIMITEDimport Thor.API.Security.LoginHandler.LoginSession;import Thor.API.Security.XLClientSecurityAssociation;import Thor.API.tcUtilityFactory;import com.thortech.util.logging.Logger;import com.thortech.xl.client.dataobj.tcDataBaseClient;import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;import com.thortech.xl.util.config.ConfigurationClient;import java.io.*;import java.util.Properties;
/* * RunSchedulerTask * * Runs an Xellerate Scheduler task from the command-line. * @author Akshat Agarwal */public class RunSchedulerTask{ /* * arg[0] : recon class name. Class must derived from SchedulerBaseTask * arg[1] : username * arg[2] : password * arg[3] : Aktask.properties is the properties file containing the Scheduler Task attributes */ public static void main(String args[]) { if (args.length < sctask =" (SchedulerBaseTask)" prop =" ConfigurationClient.getComplexSettingByPath(" tcutilityfactory =" new" attributes =" new"> 3) { attributes.load( new FileInputStream( new File(args[3]) )); scTask.setTaskAttributeMap(attributes); } // Get a database handle LoginSession loginsession = tcutilityfactory.getLoginSession(); XLClientSecurityAssociation.setGlobalLoginSession(loginsession);
tcDataBaseClient dbClient = new tcDataBaseClient(); //String s = dbClient.getDatabaseName(); scTask.setDataBase(dbClient);
// Running the Scheduler Base task scTask.runAsThread(); boolean success = scTask.isSuccess(); if (!success) { System.out.println("Scheduler Failed to Run"); String message = scTask.getStatus(); System.out.println("Status: " + message); Exception ex = scTask.getResult(); } } catch (Exception ex) { ex.printStackTrace(); } System.exit(0); }}
BUILD.xml file
task.properties
Day Max=UNLIMITED