Solved

set dba job to run every 4 hours

Posted on 2012-04-11
7
731 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

635 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