How to schedule a job to run sometimes

Paul Watson (101 posts)
October 14, 2016 08:59 AM
Accepted Answer

What are some ways that we could have a job run only during the first run of the month? Our situation is that we need to run some jobs in the middle of the flow, but only during the first run of the month. This is a simplified version of the flow. Each "run" involves many adTempus jobs.

  • run DW load
  • run DB extracts
  • If $FirstRunOfTheMonth {run HealtHelp and Catalyst}
  • run Mede

The process typically begins on Sunday, but if the first day of the month falls on a Tuesday, it might begin on Thursday.

This is complicated by the fact that, like most places, sometimes things happen that will alter the schedule. Late arriving data. Something needs to be reloaded. Etc.

I fear that a hardcoded calendar would 1) be difficult to maintain and 2) not always do the right thing if there is any variance in the operation. I would think that an adTempus variable could help, but I am not sure of the best way to go about using it.

Any suggestions?

Bill Staff (604 posts)
October 17, 2016 03:54 PM
Accepted Answer

I assume you've seen this article on making the job conditional on a Shared Schedule. This would work for your standard case. If you needed to rerun the job, you can run it manually and choose the execution option to ignore the conditions. This would only work if you run that job directly, though--if you rerun the whole chain, the conditions are going to get checked and the job won't run.

Without knowing more about your flow and other constraints, I would suggest something like this:

  • Define two job variables in your root job group (or whatever level is appropriate): "RunHealtHelp" and "RunCatalyst". Define them as Boolean type and set them to False.
  • Add a job that runs before the cycle on the first cycle of the month that sets those variables to True (using a Variable Update Task).
  • On each of those two jobs, add a job-level condition so the job only runs if its variable is True.
  • Add a step to the end of each of those two jobs to set their variable back to "False" when they run successfully

How you work this into the chain depends on your sequencing. If "Mede" is supposed to wait for the two optional jobs, then you need it like this:

"Run DB extracts" has a Response to run HealtHelp on success. HealtHelp has a Response to run Catalyst on Success or on Conditions Not Met. Catalyst has a Response to run Mede on Success or on Conditions Not Met.

If Mede doesn't need to wait for the other two, you can just have Run DB Extracts run both of them and also run Mede.

Those two jobs will only run when the variable is True. If you need to rerun them you can run them manually and tell them to ignore conditions, or you can run the job to flip the variables, or you can edit the job group to change the value of the variable that controls the job.

 

Replies are disabled for this topic.