Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: job starts at 'dbstart' ?
In article <nmyt3.23$qI1.155683_at_nnrp3.proxad.net>, Vincent GRENET
<vincent.grenet_at_free.fr> writes
>Hello all.
>
>I have a job scheduled to run at a certain time. When Oracle is not running
>at that time, the job is run when the server is restarted (dbstart).
>
>This a problem since the job can last up to one or two hours. I have seen
>nothing about that feature(?) in the documentation.
I *like* jobs to run as soon as possible after the specified time!
>
>How can I avoid that ?
If you only want it to run at certain times, look at modifying the 'next' value of the job itself. The following example tries to run between 3am and 5am:
procedure refresh_db_size (p_next_date IN OUT DATE) as begin
IF sysdate between to_date(to_char(sysdate, 'DD-MON-YY') || ' 03:00', 'DD-MON-YY HH24:MI') AND to_date(to_char(sysdate, 'DD-MON-YY') || ' 05:00', 'DD-MON-YY HH24:MI') THEN
get_db_size.tables_size; get_db_size.indexes_size; ELSIF sysdate < to_date(to_char(sysdate, 'DD-MON-YY') || ' 03:00', 'DD-MON-YY HH24:MI') THEN -- -- a little bit early for todays job -- p_next_date := to_date(to_char(sysdate, 'DD-MON- YY') || ' 03:05', 'DD-MON-YY HH24:MI'); ELSE -- -- too late for today, try again tomorrow -- p_next_date := to_date(to_char(sysdate + 1, 'DD- MON-YY') || ' 03:05', 'DD-MON-YY HH24:MI'); END IF;
You just need to include the 'NEXT_DATE' as a parameter for the job during the jobs submission e.g. the 'WHAT' for the above would be 'refresh_db_size(NEXT_DATE);'.
Andy
--
Andy Hardy. PGP key available on request