Thanks for the question, Eric.
Asked: April 12, 2017 - 3:07 pm UTC
Last updated: April 12, 2017 - 3:32 pm UTC
Version: 11gr2
Viewed 1000+ times
You Asked
AskTom,
I have an Oracle Scheduled job called "A" that runs every 5 minutes and takes 10 seconds to complete but could run longer. I have a second job called "B" that I want to run at 1 am daily. I don't want job "B" to run at the same time as job "A" so I need a way to make job "B" wait for job "A" to complete, disable job "A", run job "B" and if job "B" completes, enable job "A" (breathe). I don't know how long job "B" will take to complete because its run duration varies from 1 second to 3 hours depending on how much data it needs to process. If Job "A" fails, Job "B" is still allowed to run. If Job "B" fails, it still enables Job "A" to run.
A simpler way of saying this is that Job "A" must wait for Job "B" to complete and Job "B" must wait for Job "A" to complete.
How can I do this?
Example:
12:50 am - Job A runs and completes
12:55 am - Job A runs and completes
01:00 am - Job A runs and completes
01:00 am - Job B runs and waits for Job A. If Job A completes, Job A is disabled and Job B runs.
01:33 am - Job B completes, Job A is enabled.
01:35 am - Job A runs and completes
01:40 am - Job A runs and completes
01:44 am - Job A runs and completes
NOTE: We are strongly encouraged to use Oracle Scheduled Jobs (dbms_scheduler) and avoid dbms_job.
and Chris said...
Is this answer out of date? If it is, please let us know via a Comment