oracle9i Job不能自动执行

近期公司对所有生产数据库开启日志审计,日志审计信息默认存在sys.aud$表中,为了防止sys.aud$表增长过快,写了一个自动清除脚本,该job每隔一个小时自动删除aud$表中的信息:

 

 

create or replace procedure clear_aud
as
begin
delete sys.aud$ where timestamp# <trunc(sysdate,'HH')- 1/24;
commit;
exception when others then 
rollback;
end;
/

Variable job number ;
begin
dbms_job.submit(:job, 'clear_aud;' ,trunc( sysdate + 1 / 24 , 'hh24' ), 'trunc(sysdate+1/24,''hh24'')' );
commit ;
end ;
/

 

 

 

在实施过程中,发现有个数据库的system表空间增长很快,查看aud$发现里面有几十万条记录,但是上面的自动清理脚本已经在该数据库上执行过了,故引起该问题的原因应该是该job没有自动执行,查看dba_jobs表,发现该job存在,但是不能自动执行:

 

 

SQL> select JOB,THIS_DATE,NEXT_DATE, TOTAL_TIME,WHAT, INSTANCE from dba_jobs;

       JOB THIS_DATE  NEXT_DATE  TOTAL_TIME WHAT                   INSTANCE
---------- ---------- ---------- ---------- -------------------- ----------
         1 2011-07-11                     0 clear_aud;                    0

 

 

表dba_jobs中的next_date字段表示job下次执行的时间, 该数据库中的next_date字段为空,说明该job不会自动执行,引用该问题的原因应该是spfile中的JOB_QUEUE_PROCESSES参数被设置为0了,官方文档对该参数的解释为:

 

You can schedule routines (jobs) to be run periodically using the job queue. To schedule a job you submit it to the job queue, using the Oracle suppliedDBMS_JOBpackage, and specify the frequency at which the job is to be run. Additional functionality enables you to alter, disable, or delete a job that you previously submitted.

Job queue (Jnnn)processes execute jobs in the job queue.For each instance, these job queue processes are dynamically spawned by a coordinator job queue (CJQ0) background process. The coordinator periodically selects jobs that are ready to run from the jobs shown in theDBA_JOBSview. It orders them by time, and then spawns Jnnnprocesses to run the selected jobs. Each Jnnnprocess executes one of the selected jobs.

TheJOB_QUEUE_PROCESSESinitialization parameter controls whether a coordinator job queue process is started by an instance. If this parameter is set to 0, no coordinator job queue process is started at database startup, and consequently no job queue jobs are executed. TheJOB_QUEUE_PROCESSESinitialization parameter also specifies the maximum number of Jnnnprocesses that can concurrently run on an instance. The maximum number of processes that can be specified is 1000.
 

该参数可以动态改变,故可执行更改命令,使该参数生效:

 

ALTER SYSTEM SET JOB_QUEUE_PROCESSES = 20;
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值