Get the App
SLTechnology News&Howtos  ›  Database  › 

Oracle scheduling Schedule Features (part V)-schedule, program, job Joint

Shulou Source: shulou.com Published: 2022-06-01 06:39:39 09月19日 Update

After Oracle 10g version, scheduler divides the attributes of job into multiple parts, program is responsible for what to do, schedule is responsible for when to do, job is simple, one word: dry.

In the previous articles, we introduced creating management Jobs, creating management Programs, and creating management Schedules. Below we demonstrate how to create jobs that are executed through schedule scheduling programs through examples.

First, create a program.

begin

dbms_scheduler.create_program(program_name => 'myprogram1',

program_action => '/bin/date',

program_type => 'EXECUTABLE',

enabled => true);

end;

/

We define a program that executes the operating system command date.

2) Then define a schedule.

begin

dbms_scheduler.create_schedule(schedule_name => 'myschedule1',

start_date => sysdate,

repeat_interval => 'FREQ=DAILY ; INTERVAL=1',

comments => 'Every 1 weeks');

end;

Debugging is performed weekly. Repeat_interval can be modified depending on implementation.

3. Finally, create a job and execute the program according to the specified schedule. The operation is as follows:

begin

dbms_scheduler.create_job(job_name => 'execOScmd',

program_name => 'myprogram1',

schedule_name => 'myschedule1',

enabled => true);

end;

When creating a job, start_date,repeat_interval,job_action, etc. do not need to be specified because these parameters are controlled by the program and schedule.

After these three steps are completed, ORACLE automatically executes the operations defined in the program on a regular basis (currently set to once a week).

4. To view the current execution, query it by *_scheduler_job_run_details (*_scheduler_jobs is also available, but the information in this view is not as comprehensive as in detail).

To view the execution of the "EXECOSCMD" task you just created, execute the following command:

SQL> select job_name,job_creator,program_name,schedule_name,to_char(start_date,'yyyy-mm-dd hh34:mi:ss'),state from user_scheduler_jobs where job_name = 'EXECOSCMD';

JOB_NAME JOB_CREATOR PROGRAM_NAME SCHEDULE_NAME TO_CHAR(START_DATE, STATE

------------------------------ ------------------------------ -------------------- --------------- ------------------- ---------------

EXECOSCMD SCOTT MYPROGRAM1 MYSCHEDULE1 2018-05-14 21:45:43 SCHEDULED

How much do you know about the SCHEDULER feature in 10g? I hope you can have a general understanding of this article, and there is still a lot to learn.

Tags: Situation management command feature part scheduling operating system task information content parameter multiple instance property time step version article system view Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB Redmi OPPO Reno MySQL