cancel
Showing results for 
Search instead for 
Did you mean: 

How to kill a job chain before when another job chain starts

Former Member
0 Kudos

I need to be able to kill JOBCHAIN_A if it is still running when JOBCHAIN_B is submitted.  Is there a way to do this in CPS?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dave, you can use below redwood script. //************Query to get Running instance of the job chain       query = "Select a.* from Job a, JobDefinition b where a.JobDefinition = b.UniqueId and b.Name = '" + sJobChainName + "' and a.Status in ('R')"; //************Table iteration       for (Iterator it = jcsSession.executeObjectQuery(query, null); it.hasNext();)       {           Job j = (Job) it.next(); //************Checking for non null instances           // if (j != null)           { //************Cancelling the job chain                   j.kill();

Former Member
0 Kudos

Thanks for the quick reply Manisha1!

I'm still learning the Redwood script and can't get this to compile.  Does the query need to be a separate object?  If so what type?

basv
Explorer
0 Kudos

The query is a String object.

Former Member
0 Kudos

//***********Constant declaration********

String query = "";

String sJobChainName = (put job chain name here)

Former Member
0 Kudos

//************Query to get Running instance of the job chain

  

query = "Select a.* from Job a, JobDefinition b where a.JobDefinition = b.UniqueId and b.Name = '" + sJobChainName + "' and a.Status in ('R')";

//************Table iteration

for (Iterator it = jcsSession.executeObjectQuery(query, null); it.hasNext();)  

{      

Job j = (Job) it.next();

  //************Checking for non null instances  

  

  // if (j != null)

      

{

//************Cancelling the job chain

              

  j.kill();

Answers (0)