Running a job only if it's predecessors overlap?

All questions about Control-M jobs definitions
Post Reply
User avatar
Ross_T_Boss
Nouveau
Nouveau
Posts: 21
Joined: 08 Aug 2008 12:00

Running a job only if it's predecessors overlap?

Post by Ross_T_Boss » 08 Oct 2008 11:06

Hi,

I have a slightly odd scheduling request that I can't figure out. Anyone know if this is possible:

Job 1 is prone to overrun.
Job 2 ALWAYS needs to start at 3am.

IF job 1 + 2 overlap (i.e. job 2 starts before job 1 is completed) then job 3 runs as a successor of Job 2.
IF job 1 completes before job 2, job 3 should not run.

I am suspecting this could be done by putting a condition between job 2-3, and using a Step command to add a condition to job 3 at 3am if it's still running (haven't worked out how yet).

If it could be done using conditions this would be better, allowing for a change in runtime without having to change the Steps variables to reflect etc. It's purely a case of Job 1 + 2 running together, causes an issue that is resolved by Job 3. But it is not an option to make job 2 dependant on job 1...

Thank in advance,
Ross

User avatar
ranger67
Nouveau
Nouveau
Posts: 52
Joined: 03 Jan 2008 12:00

Post by ranger67 » 08 Oct 2008 1:46

Here's an option, but it's just a quick off the top of my head thing. I doubt it's the best that we can come up with.

Define a predecessor job (pjob) to job2. The job will run the command:

ctmpsm -listjob executing | grep job1

The on statement for the job will be:

ON stmt=* code=COMPSTAT=0
DO ForceJob job3

On stmt=* code=COMPSTAT=1
DO OK

Basically, the command will return a "0" RC if it finds that job1 is running at 3am. This would indicate that there is going to be an overlap. Then pjob will then force in job3, which has an in condition from job2, and post it's own out condition whether it forces job 3 or not. I'd probably also add a DO MAIL in addition just to notify me that the overlap process occurred.

If the command returns a "1" it did not find a running copy of job1 and therefore is being set to OK to allow job to start.

Hope this makes sense.

User avatar
gglau
Nouveau
Nouveau
Posts: 317
Joined: 13 Jun 2007 12:00

Post by gglau » 11 Oct 2008 12:14

Ronald has a good idea, but that requires something to predefine the condition JOB3_TRG-OK. Following his thought here you will Job 4 as a dummy job for this.

Job 1 -> Job 4
l->
Job 2 -> Job 3

Job 1 OUT cond Job1-TO-Job3 and Job1-TO-Job4 (both plus)
Job 2 OUT cond Job2-TO-Job3 (plus) and Job1-TO-Job4 (minus)
Job 4 OUT cond Job1-TO-Job3 (minus)

Job 3 IN cond Job1-TO-Job3 and Job2-TO-Job3

Job 2 and Job 4 has a common exclusive control resource

If Job 1 finishes before Job 2 has started, Job 4 will run which will disable Job 3.

If Job 1 finishes after Job 2 has started, Job 4 will not run because Job 2 is holding the exclusive resource. When Job 2 is done, it will disable Job 4 and Job 3 will run.

I hope this help.

User avatar
srinathk
Nouveau
Nouveau
Posts: 11
Joined: 01 May 2008 12:00

Post by srinathk » 15 Oct 2008 8:45

I appreciate ronado's response - but there is a small problem with that when Job1 FAIL and Job2 ran good after Job1 - eventhough now Job3 will run becuase Job1 did not remove the condition.

So you have to take care of removing the dummy job's condition eventhough Job1 FAIL.

Hope you guys understand my precise explonation.

Srinath.

User avatar
Ross_T_Boss
Nouveau
Nouveau
Posts: 21
Joined: 08 Aug 2008 12:00

Post by Ross_T_Boss » 16 Oct 2008 11:02

Hi all

Thanks for the replies! I was still concerned about the scenario where Job 1 gets delayed, causing it to actually start after Job 2. But this is not a problem now; after liasing with the customer in regards to the process behind the jobs, it has been determined that the following is the best course of action:

Job1 @ 0300
Job2 on completion of Job1
Job3 @ 0630, if Job1 has not completed successfully
Job2 and Job3 can not run in contention

So a little simpler, and I think all ideas here could be workable. The idea to predefine a condition is the way to go I think, effectively like using a 'NOT' logic condition:

Job0: +JOB3_TRG
Job1 @0300: +JOB1ok, -JOB3_TRG
Job2: IN JOB1ok
Job3 @0630: IN JOB3_TRG

Also Job2 and Job3 would have an exclusive resource.

Many thanks for the ideas, do you think this sounds OK? I'll put a test run in this afternoon, but so far I think this will work.

Post Reply