Control M Prerequisite Conditions
Control M Prerequisite Conditions
Robert Stinnett, July 2010 www.robertstinnett.com Prerequisite conditions in Control-M help link together jobs such that jobs cannot execute before another job has completed. This prerequisite job may have executed on the same day, or weeks ago, depending on how the job flow is setup. Conditions help you gain control over your job and workload, and can also be a powerful tool to help you decide when to run or when not to run based on other events that have taken place in the Control-M environment.
WEEKLY_KICKOFF
REPORT_COMPILER
DATABASE_MERGE
ACCTNG_REPORT
SHIPPING_REPORT
DATABASE_REORG
Here we have a typical job flow. Ive color coded it to make it easier to follow alon g. This job flow is a weekly flow, but takes several days to complete. Its ordered up on Monday and some of the jobs farther down dont complete until Thursday of the same week.
The green job WEEKLY_KICKOFF has no prerequisite conditions. In other words, it is not dependent on anything else finishing first before it can run. Keep in mind the job must still meet its quantitative and control resource requirements, as well as meet its time window and have its node available for execution. However, assuming all those are met it can run without any dependency on a job before it completing. The blue jobs, REPORT_COMPILER and DATABASE_MERGE both depend on WEEKLY_KICKOFF completing before they can run. In this instance, two jobs are dependent on a single job before it completing and posting its OUT CONDITION. Neither job will begin executing until WEEKLY_KICKOFF_OK with the order date matching the same order date as REPORT_COMPILER and DATABASE_MERGE exist in the prerequisite conditions table. Well talk more about order date and dates in general in a bit. The same principle holds true for ACCTNG_REPORT and SHIPPING_REPORT. They will not be able to execute until REPORT_COMPILER is finished; DATABASE_REORG cannot begin executing until DATABASE_MERGE is completed. Keep in mind we said earlier that this job flow can take several days to complete because some of the jobs run for a long period of time. This is where dates come into play.
Confused about where all the conditions with the same name came from? Its all about the date the original job was ordered up. Control-M stores conditions with the order date added as a field so that it can distinguish between different job flows and different dates. That way if two job flows that are exactly the same, but from different days of the week, are running it knows which conditions belong to which based off the date field. There is also a special condition type called STAT (short for STATIC) that you can use. However, its use should be limited to situations where you have an absolute need for a static condition to exist (and then you may want to give consideration to using a quantitative resource instead with a value of 1 or 0 to control the flow).
DAILYJOB_KICKOFF
(None) DAILYJOB_KICKOFF +
DAILYJOB_MERGE
DAILYJOB_KICKOFF DAILYJOB_MERGE + DAILYJOB_KICKOFF -
DAILYJOB_REPORT
DAILYJOB_MERGE DAILYJOB_MERGE -
As you can see, we are cleaning up all of our in conditions when the job finishes. Anything that was needed coming in is cleaned up after the job completes. This works for job flows for the one above where there is a straight line relationship. However, if you have job flows that branch around and in conditions are used for multiple jobs you want to be careful not to clean up conditions that are still being used. If you find yourself in a situation where you have multiple jobs using the same condition one way to clean up this common condition is with the use of a dummy job. Lets take a look at an example of this.
WEEKLY_KICKOFF
REPORT_COMPILER
DATABASE_MERGE
ACCTNG_REPORT
SHIPPING_REPORT
DATABASE_REORG
REPORT_CLEANUP
This should look familiar its the same job flow we started out with at the beginning of this document. We have the job REPORT_COMPILER that posts a condition that is used for the prerequisite conditions for two jobs. We add a third job after those two to handle the cleanup of that condition. The REPORT_CLEANUP job is a DUMMY job with the following OUT conditions: REPORT_COMPILER ACCTNG_REPORT SHIPPING_REPORT -
In order for that job to run both ACCTNG_REPORT and SHIPPING_REPORT must have completed. This dummy job simply cleans up the conditions for the REPORT_COMPILER job, plus the ACCTNG and SHIPPING report jobs.
Here Ive told Control-M that I need the conditions DBMERGE-OK AND REPOTING-OK in other to run. These both need to be present (so I put them in parenthesis) before this job can run OR the DBBACKUPOK condition must be present. So Ive created two ways for this job to kick off, either I need two conditions at the same time, or I just need one condition from a different job. Setting the relationship manually gives you a more granular control over your job flows, but remember you also have to maintain these jobs as the months and years roll by. Complex condition sets can make ongoing maintenance of jobs a nightmare.