Skip to Main Content
  • Questions
  • dbms_job is writing files to archiver frequently

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Sridevi.

Asked: November 26, 2001 - 3:20 pm UTC

Last updated: November 27, 2003 - 11:46 am UTC

Version: Oracle 7.x

Viewed 1000+ times

You Asked

In Oracle 7.x, I have scheduled a job via dbms_job in oracle.
In the init.ora file I have set the parameters :
job_queue_processes = 5
job_queue_interval = 300

Then I have submitted the job using dbms_job.submit.
I have scheduled the job to run every day at 1:30 pm.
The syntax being:
dbms_job.submit(p_job_number, 'myproc', sysdate, trunc(sysdate)+13.5/24, false);

The job runs as scheduled at 1:30 pm. But from 1:30 pm onwards it startes writing one file to the archiver log every minute or so. However it does not run my procedure every minute.

I have tried this even with a simple null procedure.
In other words, I have tried this with a procedure like this:
Procedure myproc is
Begin
null;
End;

It still writes to the archiver, after it runs once on the scheduled time. And continues to write to the archiver every minute or so. I have even tried this on a just started database with no writes/reads
being done to it from any logins. So the culprit is the job.

This writing to the archiver stops if I kill the job using dbms_job.remove or I shutdown the database.

Why does this happen? How can i prevent these frequent entries into the archiver log.


and Tom said...

what do you mean by "writing one file to the archiver log every minute of so"???


You do realize that you have somewhat of an infinite loop going there.

scott@ORA815.US.ORACLE.COM> l
1* alter session set nls_date_format = 'dd-mon-yyyy hh24:mi:ss'
scott@ORA815.US.ORACLE.COM> select trunc(sysdate)+13.5/24 from dual;

TRUNC(SYSDATE)+13.5/
--------------------
26-nov-2001 13:30:00

you do realize that INTERVAL should be a string -- that should be

dbms_job.submit
(p_job_number, 'myproc', sysdate, 'trunc(sysdate)+13.5/24', false);
^^^ ^^^

And that it probably should actually be:

dbms_job.submit
(p_job_number, 'myproc', sysdate, 'trunc(sysdate)+1+13.5/24', false);
^^^ ^^^ ^^^

if you want it to run every DAY at 1:30pm. You constantly reschedule it for 1:30pm TODAY. Everytime we run the job, it FAILS. Consider (if you schedule this job AFTER 1:30 in the afternoon)

scott@ORA815.US.ORACLE.COM> exec dbms_job.submit( :n, 'null;', sysdate, 'trunc(sysdate)+13.5/24', false );
BEGIN dbms_job.submit( :n, 'null;', sysdate, 'trunc(sysdate)+13.5/24', false ); END;

*
ERROR at line 1:
ORA-23420: interval must evaluate to a time in the future
ORA-06512: at "SYS.DBMS_JOB", line 50
ORA-06512: at "SYS.DBMS_JOB", line 138
ORA-06512: at line 1


You need to add one to the date.

What I believe is happening (and your alert log will confirm) is that we are trying to run the job -- but we cannot since the NEXT evaluates to a time in the PAST (until midnight of course -- then it works, all will be quiet until 1:30pm at which point the whole cycle begins again).




Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

ORA-23420

A reader, July 01, 2002 - 9:56 am UTC

Hi Tom

I am getting ORA-23420 when trying to submit a job with interval of 30 minutes.

begin
select instance_number into :instno from v$instance;
dbms_job.submit(:jobno, 'statspack.snap;', trunc(sysdate+1/24,'HH'), 'trunc(SYSDATE,''HH'')+1/48', TRUE, :instno);
commit;
end;
/

how can we avoid this error and submit a job with 30 minutes interval?

Tom Kyte
July 01, 2002 - 10:39 am UTC

> oerr ora 23420
23420, 00000, "interval must evaluate to a time in the future"
// *Cause: The parameter "interval" evaluates to a time earlier than SYSDATE.
// *Action: Choose an expression that evaluates to a time later than SYSDATE.
//

There is an error in your logic.

Suppose it is 1:45pm right now. Well, the trunc of 1:45pm to the hour would be -- 1:00pm, you add 30 minutes to that and get 1:30pm -- today -- a date in the past!


Assuming that if it is between :00 and :29 after the hour that you want to run again at :30 and if it is between :30 and :59 past the hour, you want to run on the next hour, you can use:


trunc(sysdate,'hh')+(1/24/60*30)*(1+trunc(to_char(sysdate,'mi')/30))

That'll add either 30 or 60 minutes to the trunc of sysdate to the hour depending on whether the minutes are between 0 and 29 or 30 and 59...




runs job every 15 minutes

A reader, November 27, 2003 - 11:38 am UTC

Hi

From your last solution the jobs runs every 30 minutes, 00:00, 00:30 for example

Can we run jobs every 15 minutes? Such as

12:34, 12:49, 13:04

:-?

Tom Kyte
November 27, 2003 - 11:46 am UTC

sure, interval of

sysdate+15*(1/24/60)

does that with a "little slide" possible -- meaning the job will be scheduled to run 15 minutes after the time it was last started to run.


If you don't want it to slide -- you want 00, 15, 30, 45 -- just do the math like I did above for 00 and 30

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library