If you have a job that has been running for an abnormally long period of time, you may want to abort it. Use the STOP_JOB procedure to stop a currently running job.
This example stops the RMAN_BACKUP job while it is running:
SQL> exec dbms_scheduler.stop_job(job_name=>’rman_backup’);
The STATUS column of DBA_SCHEDULER_JOB_LOG will show STOPPED for jobs stopped using the STOP_JOB procedure.
Disabling a Job
You may want to temporarily disable a job because it is not running correctly. You need to ensure that the job does not run while you are troubleshooting the issue. Use the DISABLE procedure to disable a job:
SQL> exec dbms_scheduler.disable(‘rman_backup’);
If the job is currently running, consider stopping the job first or using the FORCE option of the DISABLE procedure:
SQL> exec dbms_scheduler.disable(name=>’rman_backup’,force=>true);
Enabling a Job
You can enable a previously disabled job via the ENABLE procedure of the DBMS_ SCHEDULER package. This example re-enables the RMAN_BACKUP job:
SQL> exec dbms_scheduler.enable(name=>’rman_backup’);
Tip You can check to see if a job has been disabled or enabled by selecting the ENABLED column from the DBA_SCHEDULER_JOBS view.
Copying a Job
If you have a current job that you want to clone, you can use the COPY_JOB procedure to accomplish this.
The procedure takes two arguments: the old job name and the new job name. Here is an example of copying a job, where RMAN_BACKUP is a previously created job, and RMAN_NEW_BACK is the new job that will be created:
SQL> begin dbms_scheduler.copy_job(‘rman_backup’,’rman_new_back’);end; /
The copied job will be created but not enabled. You must enable the job first (see the previous section for an example) before it will run.
Running a Job Manually
You can manually run a job outside its regular schedule. You might want to do this to test the job to ensure that it is working correctly. Use the RUN_JOB procedure to initiate a job manually.
This example manually runs the previously created RMAN_BACKUP job:
SQL> begin dbms_scheduler.run_job( job_name => ‘rman_backup’, use_current_session => false); end;
The USE_CURRENT_SESSION parameter instructs Oracle Scheduler to run the job as the current user (or not). A value of FALSE instructs the scheduler to run the job as the user who originally created and scheduled the job.
Leave a Reply