4 Replies Latest reply: Jun 25, 2014 8:10 AM by User_Sep RSS

    Database scheduler runs on server startup

    User_Sep

      Dear Experts,

       

      I am using Oracle 10g Database, I am using a DB scheduler which is set to run on 6PM daily.

       

      But when I start my server at morning 8 AM, the scheduler said above executes.

       

      Any ideas appreciated.

       

      Thanks in advance.

       

      -Sep

        • 1. Re: Database scheduler runs on server startup
          PhilHerring

          Are you saying that the DB is shut down before the job executes, and runs on startup? I'd expect that.

           

          It would help a lot if you post the script that created the job.

          • 2. Re: Database scheduler runs on server startup
            Sven W.

            User_Sep wrote:

             

            ...

             

            Any ideas appreciated.

             

            Let your server run at night (or at least till 9 p.m.).

            A server is not something you should need to constantly start and stop.

             

             

            Apart from that, the Oracle scheduler has the possibility to define time windows and schedules  which can define when specific job is allowd to run. For better info see the docs: DBMS_SCHEDULER

            • 3. Re: Database scheduler runs on server startup
              GregV

              Hi,

               

              It probably means your server was not up at the time the job was supposed to run. If it's something you frequently do, you may consider changing your job's start date.

              • 4. Re: Database scheduler runs on server startup
                User_Sep

                BEGIN

                  SYS.DBMS_SCHEDULER.DROP_JOB

                    (job_name  => 'DB.NEXT_ACT');

                END;

                /

                 

                 

                BEGIN

                  SYS.DBMS_SCHEDULER.CREATE_JOB

                    (

                       job_name        => 'DB.NEXT_ACT'

                      ,start_date      => TO_TIMESTAMP_TZ('2014/04/21 15:52:49.000000 +05:30','yyyy/mm/dd hh24:mi:ss.ff tzr')

                      ,repeat_interval => 'FREQ=DAILY;BYHOUR=18;BYMINUTE=00'

                      ,end_date        => NULL

                      ,job_class       => 'DEFAULT_JOB_CLASS'

                      ,job_type        => 'PLSQL_BLOCK'

                      ,job_action      => 'BEGIN ACTIVITIY(''TEST'',1); END;'

                      ,comments        => 'TESTING'

                    );

                  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE

                    ( name      => 'DB.NEXT_ACT'

                     ,attribute => 'RESTARTABLE'

                     ,value     => FALSE);

                  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE

                    ( name      => 'DB.NEXT_ACT'

                     ,attribute => 'LOGGING_LEVEL'

                     ,value     => SYS.DBMS_SCHEDULER.LOGGING_RUNS);

                  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL

                    ( name      => 'DB.NEXT_ACT'

                     ,attribute => 'MAX_FAILURES');

                  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL

                    ( name      => 'DB.NEXT_ACT'

                     ,attribute => 'MAX_RUNS');

                  BEGIN

                    SYS.DBMS_SCHEDULER.SET_ATTRIBUTE

                      ( name      => 'DB.NEXT_ACT'

                       ,attribute => 'STOP_ON_WINDOW_CLOSE'

                       ,value     => FALSE);

                  EXCEPTION

                    -- could fail if program is of type EXECUTABLE...

                    WHEN OTHERS THEN

                      NULL;

                  END;

                  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE

                    ( name      => 'DB.NEXT_ACT'

                     ,attribute => 'JOB_PRIORITY'

                     ,value     => 3);

                  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL

                    ( name      => 'DB.NEXT_ACT'

                     ,attribute => 'SCHEDULE_LIMIT');

                  SYS.DBMS_SCHEDULER.SET_ATTRIBUTE

                    ( name      => 'DB.NEXT_ACT'

                     ,attribute => 'AUTO_DROP'

                     ,value     => TRUE);

                 

                 

                  SYS.DBMS_SCHEDULER.ENABLE

                    (name                  => 'DB.NEXT_ACT');

                END;

                /