HOW to prevent two tables execute together

All questions about Control-M jobs definitions
Post Reply
User avatar
mauriziog
Nouveau
Nouveau
Posts: 807
Joined: 08 Jun 2007 12:00
Location: Varese - Italy
Contact:

HOW to prevent two tables execute together

Post by mauriziog » 04 Oct 2007 11:21

If I have two indipendent tables, with inside two jobs each.
The two tables are different do different jobs but is one of them is executing the second one must wait the end of the first and viceversa.
The two tables are in different flows, and can start at different times: no problem. Or the second can start when the first in not yet finished.

How is the best method to prevent that this two tables execute together?

User avatar
Walty
Nouveau
Nouveau
Posts: 473
Joined: 20 Jan 2006 12:00

Post by Walty » 05 Oct 2007 3:03

Suggestion:

You have application A with 4 jobs

- JOB-01 check&set Global Variable (by script1)
- JOB-02 is your first application job
- JOB-03 is the second application job
- JOB-04 delete the Global Variable (by script2)

You have application B with 4 jobs

- JOB-01-B check&set Global Variable (by script1)
- JOB-02-B is your first application job
- JOB-03-B is the second application job
- JOB-04-B delete the Global Variable (by script2)

1) Define JOB-01, JOB-04, JOB-01-B and JOB-04-B with same Control Resource in Exclusive Mode
2) On JOB-01 and JOB-01-B Set Rerun Interval <your choice> and Maximum <your choise>
3) On JOB-01 and JOB-01-B Set
ON STMT=*
COMPSTAT=2
DO RERUN


Description of this method:

- The first job of application A or B check and set the Global Variable (example RUNNING)
- This job is serialised by Control Resource
- If the Global Variable is already SET, this job is put in rerun mode with your choise <interval> and <max rerun> , the job wait until the Global Variable is DELETED by the last job of the active application.

- The first job set a Global Variable by script1

#!/usr/bin/csh
unset verbose
set Task_Id='RUNNING'
set Var1=`ctmvar -action LIST | grep "%%\TESTGLOBVAR" | awk '{print $2}'`
set Var2='RUNNING'
if ${Var1} == ${Var2} then
echo "Run not possible because actual status is: RUNNING"
echo "Job is put in RERUN mode and wait 2 minutes"
exit 2
else
echo "Run possible because actual status is NOT RUNNING"
echo "Gloval variable is set to RUNNING"
ctmvar -action SET -var "%%\TESTGLOBVAR" -varexpr ${Task_Id}
endif
exit


- The last job of application A or B delete the Global Variable used
- This job is serialised by Control Resource

- The last job delete a Global Variable by this scrip2

#!/usr/bin/csh
unset verbose
echo "Gloval variable is DELETED"
ctmvar -action DELETE -var "%%\TESTGLOBVAR"
exit

Regards
Walty

User avatar
mauriziog
Nouveau
Nouveau
Posts: 807
Joined: 08 Jun 2007 12:00
Location: Varese - Italy
Contact:

Post by mauriziog » 12 Oct 2007 2:52

You use the valiables to do this.
Is another way, I do this with the combination of resources and condition.

I have in the first jobs of the two tables one control exclusive resourse.
So if the first job is still running when the secont table's first job whant to start: it dont start because have the same resource.

This for the first but the others?
I put a condition, a "control condition".
This condition is always in the controlm and is STAT.
And the first jobs af the tables have this condition as IN_CONDITION.
This condition is deleted after the first job ends, and added at the end of the table: the alst job add it when ends.

So when the first job ends delete the condition, the second jobs of the same table starts but the first job of the second table not: because have the resource but not the condition ! And so waits that all the first table ends and ends OK.

User avatar
fyot
Nouveau
Nouveau
Posts: 736
Joined: 26 Apr 2005 12:00
Location: PARIS
Contact:

Post by fyot » 13 Oct 2007 7:55

Hi mauriziog

I already had that sort of problem.
Using same way with Control Resources and Condition here is a solution i found.

Using a condition like GO in your chain.
The first job of your chain delete that condition and only the last is able to create again that condition.

In that case only one chain can run.
So your first job could start in a same time with another one.

Using Control Ressource in exclusive mode, you can reduce that risk.

But your first job can't be a DUMMY job. If you see job logs, you will see that the Control Ressource is released before to delete the condition.

Solution I found, is the first job must launch a command to delete GO condition, using ctmcontb. In that case condition will be deleted before release of Control Ressource.

User avatar
mauriziog
Nouveau
Nouveau
Posts: 807
Joined: 08 Jun 2007 12:00
Location: Varese - Italy
Contact:

Post by mauriziog » 17 Oct 2007 10:09

fyot wrote:Using Control Ressource in exclusive mode, you can reduce that risk.

But your first job can't be a DUMMY job. If you see job logs, you will see that the Control Ressource is released before to delete the condition.

Solution I found, is the first job must launch a command to delete GO condition, using ctmcontb. In that case condition will be deleted before release of Control Ressource.
Thanks to report this, the first job if is dummy, I change task type of this job in "command" with a sleep command.
But I think that YOUR solution is better, is more precise.
Thanks fyot.

Post Reply