How To: Perform an action if a job has not run by a certain time
Responses allow you to respond to problems or other events that occur during job execution. Sometimes it can also be useful to perform an action if a job does not run when expected.
For example, suppose you have a job that is executed each day when a data file is uploaded to the server (using a File Trigger). You want to be notified if that file has not arrived by 4:00 pm. You can accomplish this using a second job (the we'll call it the "Notification Job") that has a condition on the original job (the "File Processing Job").
Configure the Notification Job as follows:
- On the Triggers page, add a Schedule Trigger to schedule the job to run at 4:00 each day.
- On the Conditions page, select the Skip the job option.
-
Add a Job Condition configured as follows:
- Depend on job: Select the File Processing Job.
- Rule: Job has not run.
- Instance: Any since previous execution of current job.
- Condition wait: Do not wait for condition to be met.
- On the Steps page, add a Notification Task to send notification to the appropriate recipient(s).
When the Notification Job is triggered at 4:00 each day, adTempus will check to see if the File Processing Job has run since the last time the Notification Job ran. If it has, the condition will not be satisfied, and the notification message will not be sent. If the File Processing Job has not run, the condition will be satisfied, and the notification message will be sent.
Some additional configuration may be required depending on your workflow. For example, supposed that the Files Processing Job has not run at 4:00 on Tuesday, so the Notification Job runs. You resolve the problem that caused the file to not be transferred on time, and the file is now transferred at 4:30, causing the File Processing Job to run. Now supposed that on Wednesday, there is again a problem with the transfer and the file does not arrive on time. However, when the Notification Job runs at 4:00, it finds the instance of the File Processing Job that ran on Tuesday at 4:30 (after the Notification Job had run). This causes the condition for the Notification Job to fail, so notification is not sent.
There are several ways to avoid this problem:
- Use a Cycle ID for the group that contains the two jobs, and change the Instance rule for the condition to "Any in same cycle."
- Add a File Trigger to the Notification Job that targets the File Processing Job, so that the Notification Job will always run right after the File Processing Job. The job won't do anything when it is triggered this way (because its condition will not be met), but this will "reset" the dependency chain so that the File Processing Job must run again before the next scheduled execution of the Notification Job.