Solved

set dba job to run every 4 hours

Posted on 2012-04-11
7
717 Views
Last Modified: 2012-05-01
I want a job to run every 4 hours not every 4 hours after the previous run completed.

I am not sure what the SYSDATE should be.


SYSDATE+240/1440  this isn't what I want.
0
Comment
Question by:mw-hosting
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37834515
>>this isn't what I want.

That is 4 hours from now.  If that is the interval for the job, it will run every 4 hours.

What about this isn't what you want?
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 500 total points
ID: 37834523
assuming you mean 00:00:00,  04:00:00,  08:00:00, 12:00:00,16:00:00, 20:00:00

try this...


trunc(sysdate)+(mod(to_char(sysdate,'hh'),6)+1)*4/24
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 500 total points
ID: 37834555
also, you might want to look into using dbms_scheduler instead of dbms_job

BEGIN
    DBMS_SCHEDULER.create_job(
        job_name         => 'YOUR_EVERY_4_HOUR_JOB_NAME',
        job_type         => 'PLSQL_BLOCK',
        job_action       => 'begin null; end; ',  --- put your code here
        start_date       => TRUNC(SYSDATE)+1,  -- start tomorrow or whenever you want
        repeat_interval  => 'FREQ=daily;BYHOUR=0,4,8,12,16,20;BYMINUTE=0;BYSECOND=0',
        enabled          => TRUE,
        comments         => 'This ought to do it');
END;
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:David
ID: 37834850
Nice example, Sean.
0
 

Accepted Solution

by:
mw-hosting earned 0 total points
ID: 37898716
I applied this:

'TRUNC(SYSDATE+4/24,''HH'')'

I don't have the option to use dbms_scheduler, thanks though.
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37898986
37898716 --- this allows for drift if your process takes more than an hour to run.
0
 

Author Closing Comment

by:mw-hosting
ID: 37913874
Another option that allows every 4 hours, not depended on the hour provided.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question