3

How can I ensure that a dbms_scheduler job will never have more than one instance running?

For example, if I have a job that is scheduled to run once a minute, but it actually runs for three minutes, I don't want a second and third instance of the job to start and run concurrently.

(note) I previously asked this question specifying that either dbms_scheduler or dbms_jobs solutions were acceptable. I have since learned that dbms_jobs does not work well on RAC, hence this dbms_scheduler-specific question. (end note)

2
  • Can you schedule the job using a bash script?
    – Vérace
    Commented Aug 12, 2015 at 7:27
  • Query dba_scheduler_jobs_running to see if the job is already running, and exit if it is Commented Oct 10, 2016 at 13:16

2 Answers 2

2

yes, you can, this in fact is default behaviour. See Database Administrator’s Guide chapter 29 Scheduling Jobs with Oracle Scheduler

Immediately after a job starts, the repeat_interval is evaluated to determine the next scheduled execution time of the job. While this might arrive while the job is still running, a new instance of the job does not start until the current one completes.

0

Doesn't this accomplish the same thing that @Justin Cave did in the other thread?

BEGIN
DBMS_SCHEDULER.CREATE_JOB 
(
   job_name             => 'hr.employees_jobs',
   job_type             => 'PLSQL_BLOCK',
   job_action           => 'BEGIN proc_that_takes_3_minutes; END;',
   start_date           => systimestamp,  
   repeat_interval      => 'FREQ=MINUTELY;INTERVAL=1',
   enabled              =>  TRUE,
   comments             => 'Gather table stats on hr.employees'
) ;
END ;
/
1
  • 2
    by my understanding, dbms_job reschedules at the end of each job run, whereas dbms_scheduler starts at the scheduled time even if another job is running. Commented Aug 12, 2015 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.