How To: Link Jobs Together
Often you will want to link two or more jobs together so that one job is run when another finishes. In adTempus this is done using either Responses that run Job Control Actions or with Job Triggers. In many cases the two approaches are interchangeable, but there are some differences.
When you use Job Control Actions:
- The Action is configured on the "source" job: If you want Job 2 to run when Job 1 succeeds, you add a Job Control Action to Job 1 to have it run Job 2 (the "target" job).
- You have more control over the circumstances in which the target job is run. For example, you could run the target job only if a step in the source job returns a particular exit code.
- You have more control over how the target job is run: you can specify which step(s) should be run, decide whether Responses should be run, ignore Conditions for the job, and control which target servers the job runs on.
- The Action can be blocked from running if the target job is held.
When you use Job Triggers:
- The Trigger is configured on the "target" job: You add a Job Trigger to Job 2 telling it to run when Job 1 succeeds.
- You can configure the trigger to fire based on more than one job, when all or any of the source jobs has run.
- You have more control over which instances of the source job can trigger the target.
Linking with a Job Control Action
In this example we will run the "Target" job when the "Source" job succeeds.
- Create and save both the Source job and the Target job .
- Edit the Source job and go to the Responses page of the Job Properties.
- Click Add to add a new Response.
- In the Response Properties window, go to the Events section and click Add.
- In the Response Event Properties window, select the "Job Succeeded" event and click OK.
- Back in the Response Properties window, go to the Actions section and click Add.
- In the Select Action window, select "Control a job or job step" and click OK.
-
In the Job Control Action Properties window,
- Select the "Run a job" action.
- Under Applies To, select Another job on the same computer, then click Select... and select the Target job.
- Configure any other options as desired.
- Click OK to save the Action.
- Click OK to save the Response, and OK again to save the job.
The jobs are now linked together (no configuration is required on the Target job).
In this example we want the Target job to run when the Source job succeeds. The link can also be based on many other criteria. For example, you could run a different Target job when the Source job fails. This is determined by the Event that you selected in step 5 above. See the Job Responses topic for information on the other Events that are available.
You could also run the Response from a particular step instead by using the Responses page of the step properties. This allows you to choose from additional events, such as running the Target job based on the exit code from a program that you run.
Linking with a Job Trigger
In this example we will again run the "Target" job when the "Source" job succeeds.
- Create and save both the Source job and the Target job .
- Edit the Target job and go to the Triggers page of the Job Properties.
- Click Add to add a new Trigger.
- In the Select Trigger Type window, select "Execute in response to another job" and click OK.
- In the Job Trigger Properties window, click Add on the Job Trigger page to add a new trigger rule.
-
In the Job Trigger Target Rule window,
- Under Trigger based on job, select Another job on the same computer, then click Select... and select the Source job.
- Leave all other settings at their default
- Click OK to save the rule.
- Click OK to save the trigger, and OK again to save the job.
The jobs are now linked together (no configuration is required on the Source job).