APEX_PLSQL_JOB: How to end/kill jobs

Hi,
I'm wondering if there's a good way to kill jobs that were created using APEX_PLSQL_JOB.
I have a situation where I create a job using APEX_PLSQL_JOB. The process that it is executing will take a long time to run. After a while I decide that I need to end this job since it's slowing down the server. How can I terminate it?
I've tried the following:
- Kill the Oracle session that is executing the code. This terminated the process but just restarted it again a few seconds later
- Purge the process using APEX_PLSQL_JOB.PURGE_PROCESS. This removed it from the list of APEX PL_SQL jobs in the APEX_PLSQL_JOBS view. It had no effect on the processing of the job.
Any other ideas on how I can kill the process that I started?
Thank you,
Martin
[http://apex-smb.blogspot.com/]

On a related note, this is yet another great example of when to use the database resource manager. You could:
- create a resource consumer group called "LONG_RUNNING_STUFF"
- that group gets dropped to say 5% CPU after 5 min (just as an example)
- any session in that group that has an operation that lasts longer than 20 minutes automatically killed (just as an example)
- in your job code, make a call to DBMS_SESSION.SWITCH_CURRENT_CONSUMER_GROUP() to have that session put itself into the LONG_RUNNING_STUFF group (you need to assign a priv for this)
It's a great way to let the db manage itself so you don't have to monitor sessions. You might also consider instrumenting your code with dbms_application_info.set_session_longops()
Tyler Muth
http://tylermuth.wordpress.com
[Applied Oracle Security: Developing Secure Database and Middleware Environments|http://sn.im/aos.book]

Similar Messages

  • I DON'T WANT TO UPGRADE OR HAVE AN ADD ON EVER, DISABLING UPDATES DOES NOT WORK, HOW DO I KILL ALL MEASAGES FOR UP GRADES AND ADD ON'S FOR EVER, ONCE AND FOR ALL, COMPLETELY, THE END AND NEVER BE BOTHERED AGAIN EVER!

    I DON'T WANT TO UPGRADE OR HAVE AN ADD ON EVER, DISABLING UPDATES DOES NOT WORK, HOW DO I KILL ALL MESSAGES FOR UP GRADES AND ADD ON'S FOR EVER, ONCE AND FOR ALL, COMPLETELY, THE END AND NEVER BE BOTHERED AGAIN EVER! ALSO IF I KILL MYSELF I WILL HOLD YOU PERSONALTY RESPONSIBLE.edit

    There is a world of information in these forums if you use the search function near the top right of this page. Just type in NAS for example and you get many threads on the subject (marked with a green checkmark if it solved the question) another example would be Airport Exterme and sound system. Once you formulate your ideas better then specific questions can be addressed one at a time. You may find that a less expensive choice for a server might be a mac mini. Good luck with your project, ask more specific questions and update you systems profile.

  • How can i kill a job in BW

    Hi,
    Any budy please help me that how can i kill a background job in BW
    Cheers,
    KGB

    hi u can kill job in SM 37 also.
    also u can cancel in SM50.also use tis link
    How to stop scheduled job in bw.
    Hope it solves your query
    Thanks,
    pathak
    Edited by: npathak on Aug 2, 2010 9:09 PM

  • How to drop/kill/end a MeetMe conference

    Hi,
    We have an issue that a MeetMe conference call has been opened and apparently has not been closed by one last participant.
    Unfortunately we do not know who it is and the participant also apparently is not aware that the line is still open. So how do we kill it?
    I've googled and searched the support community and came to the conclusion that it's not possible to kill it like you could kill it in an adhoc conference. There's a whole lot of links and docs and situations that are being referred too but no where a simple answer as to what I can do to kill this MeetMe session. So, what can I do?  Do I need to reboot the callmanager cluster, or can I kill it by disabling/enabling a service, or maybe deleting the MeetMe number and creating it again? Anyone has a simple answer?
    A second les important question I have is, is there a way to see who the active/current participants are in a MeetMe?
    Thanks in advance
    Regards,

    Restart the IPVMS, and no, the list functionality for conferences only works with ad-hoc
    HTH
    java
    if this helps, please rate
    www.cisco.com/go/pdihelpdesk

  • How to schedule the job to run evry Sunday at 12 P.M IST.

    Hi Experts,
    I want to schedule a job which will run evry Sunday at 12 P.M IST.
    I have written the below script.
    [code]BEGIN
      SYS.DBMS_SCHEDULER.CREATE_JOB
           job_name        => 'SERVICE_SAL_FS.SAL_MESSAGE_BUFFER_PURGE_JOB'
          ,start_date      =>  SYSTIMESTAMP
          ,repeat_interval => 'FREQ=WEEKLY; BYDAY=SUN; BYHOUR=12;BYMINUTE=0; BYSECOND=0;'
          ,end_date        =>  NULL
          ,job_class       => 'DEFAULT_JOB_CLASS'
          ,job_type        => 'STORED_PROCEDURE'
          ,job_action      => 'SERVICE_SAL_FS.SAL_MESSAGE_BUFFER_PURGE_PROC'
          ,comments        => 'Run at 12 P.M.IST every Sunday'
          ,enabled            => TRUE
    END;[/code]
    But the server in US.
    [code]SELECT sysdate from Dual;
    6/11/2013 3:58:58 AM
    --But the time in India is 02:28 PM [/code]
    How to convert the timezone to IST.
    Please help me how to schedule the job to run evry Sunday at 12 P.M IST.
    Thanks.

    Did you read DBMS_SCHEDULER docs:
      The calendaring syntax does not allow you to specify a time zone. Instead the Scheduler retrieves the time zone from the start_date argument. If jobs must follow daylight savings adjustments you must make sure that you specify a region name for the time zone of the start_date. For example specifying the start_date time zone as 'US/Eastern' in New York will make sure that daylight saving adjustments are automatically applied. If instead the time zone of the start_date is set to an absolute offset, such as '-5:00', daylight savings adjustments are not followed and your job execution will be off by an hour half of the year.
      When start_date is NULL, the Scheduler will determine the time zone for the repeat interval as follows: 
    It will check whether the session time zone is a region name. The session time zone can be set by either:
    Issuing an ALTER SESSION statement, for example:
    SQL> ALTER SESSION SET time_zone = 'Asia/Shanghai'; 
      Setting the ORA_SDTZ environment variable.
      If the session time zone is an absolute offset instead of a region name, the Scheduler will use the value of the DEFAULT_TIMEZONE Scheduler attribute. For more information, see the SET_SCHEDULER_ATTRIBUTE Procedure.
      If the DEFAULT_TIMEZONE attribute is NULL, the Scheduler will use the time zone of systimestamp when the job or window is enabled.
    SY.

  • How to make a job run on a appointed node

    I have a problem. The database is Oracle 10g, RAC, two nodes
    There are some job which run on everyday night. Now, something happened, the job run on Node A can't work as normal, but if run on node B, It will work well.
    so I just want to submit the jobs on Node B, I submited the jobs on Node B, but the jobs always run on Node A.
    I want to know how to make a job run on a appointed node.

    the Job just transfer some procedure to add partitions for some table, to merge the records from some tables to one table and so on.
    the problem is when the job run on Node A, it is very very slow, the procedure would run hours and not success end, but if on Node B it will successfully end in seconds.
    restart the Node A would be a way for the problem, but may it will leave a hidden trouble. I want save the scene to find out the problem
    so can you help me

  • How to run a job in background programatically after 10 sec

    Hi Forum,
    Can anyone tell me How to run a job in background programatically after 10 sec..
    Thanks in advance

    Hi,
    Here is the example code
    *Submit report as job(i.e. in background) 
    data: jobname like tbtcjob-jobname value
                                 ' TRANSFER TRANSLATION'.
    data: jobcount like tbtcjob-jobcount,
          host like msxxlist-host.
    data: begin of starttime.
            include structure tbtcstrt.
    data: end of starttime.
    data: starttimeimmediate like btch0000-char1.
    * Job open
      call function 'JOB_OPEN'
           exporting
                delanfrep        = ' '
                jobgroup         = ' '
                jobname          = jobname
                sdlstrtdt        = sy-datum    " You need to give the Date for execution the Job
                sdlstrttm        = sy-uzeit    " You need to give the Time for execution the Job
           importing
                jobcount         = jobcount
           exceptions
                cant_create_job  = 01
                invalid_job_data = 02
                jobname_missing  = 03.
      if sy-subrc ne 0.
                                           "error processing
      endif.
    * Insert process into job
    SUBMIT zreport and return
                    with p_param1 = 'value'
                    with p_param2 = 'value'
                    user sy-uname
                    via job jobname
                    number jobcount.
      if sy-subrc > 0.
                                           "error processing
      endif.
    * Close job
      starttime-sdlstrtdt = sy-datum + 1.
      starttime-sdlstrttm = '220000'.
      call function 'JOB_CLOSE'
           exporting
                event_id             = starttime-eventid
                event_param          = starttime-eventparm
                event_periodic       = starttime-periodic
                jobcount             = jobcount
                jobname              = jobname
                laststrtdt           = starttime-laststrtdt
                laststrttm           = starttime-laststrttm
                prddays              = 1
                prdhours             = 0
                prdmins              = 0
                prdmonths            = 0
                prdweeks             = 0
                sdlstrtdt            = starttime-sdlstrtdt
                sdlstrttm            = starttime-sdlstrttm
                strtimmed            = starttimeimmediate
                targetsystem         = host
           exceptions
                cant_start_immediate = 01
                invalid_startdate    = 02
                jobname_missing      = 03
                job_close_failed     = 04
                job_nosteps          = 05
                job_notex            = 06
                lock_failed          = 07
                others               = 99.
      if sy-subrc eq 0.
                                           "error processing
      endif.
    Regards
    Sudheer

  • How to schedule a job which needs to run evry day 1(AM) o clk?

    begin
    DBMS_SCHEDULER.create_job (
    job_name=> 'BJAZPROPMAINTAIN',
    job_type=> 'PLSQL_BLOCK',
    job_action=> schemaname.schedule_procedure;',
    start_date=> '02-aug-08 01:00:00 PM',
    repeat_interval=> 'FREQ=DAILY; BYHOUR=01',
    enabled =>TRUE,
    auto_drop=>FALSE);
    end;
    Hi all,
    i want to schedule a job which needs to be run every day one o clock early morning i haven't set the job_scheduler before this. by searching thru net and prev scheduler coding i have written the above code here for running evry day early morning 1 o clock i m little bit of confused in the time
    repeat_interval=>'FREQ=DAILY;BYHOUR=01'; whether is is correct one or wrong?
    and also there are some other job is scheduled in the same time . will it create any problem of executing at the sametime or we need to change the timing of 1:15 like that?
    please advise me..

    Thanks a lot so it will be executing every night 1 o clock am i right?
    It should.But I shall say that schedule it and than only we can be sure about it.About the timing part, its correct syntatically.
    i saw that job_priority column in dba_scheduler_jobs table but dont know what it does?
    and also how can fetch this job scheduler sid,serial# i checked v$session but how to correlate this ..
    please explain me
    In schedulerjobs,there is a column ,client_id.You can map it to the sid from the V$session.I don't have a box running Oracle at the moment so I wont be test it for you.Do it and post feedback.
    what will happen if more than one job is scheduled in the sametime
    i think for this only we set the priority on the two which one needs to be first exec(depends on the high priority)
    let me know about this.
    Jobs are prioritized by two parts,within the class they are a part of and individualy.If you have two jobs in the same class than they can be make run with a different priority with the priority clause set within them.This has a number which start from 1 meaning highest priority.So if there are two jobs scheduled for the same time,you need to check which job class they fall into. If they are in the same class than you have to change the priority of them.
    I suggest you read the books,they cover all these topics in much more detail.
    Also there is a dedicated forum about Scheduler.In future for Scheduler regarded questions, you can visit there.
    Scheduler
    Aman....

  • How to check my job name from the database...

    I have written one job scheduler which is as follows :
    SQL> ED
    Wrote file afiedt.buf
    1 DECLARE
    2 X NUMBER;
    3 JobNumber NUMBER;
    4 BEGIN
    5 SYS.DBMS_JOB.SUBMIT
    6 (
    7 job => X
    8 ,what => 'scott.SPLITSMS;'
    9 ,next_date => SYSDATE+1/1440
    10 ,interval => 'SYSDATE+1/1440 '
    11 ,no_parse => FALSE
    12 );
    13 JobNumber := to_char(X);
    14* END;
    15 /
    PL/SQL procedure successfully completed.
    Now I want to check whether the job has been really created or not?
    so for that I have used the following command line:
    SQL> SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS';
    SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS'
    ERROR at line 1:
    ORA-00942: table or view does not exist
    how to check my job name from the database...
    what is the command used to check the job_name ????
    and how can i ensure that my job scheduler is running properly...???
    please help ........my dear friends.....!

    957029 wrote:
    Now I want to check whether the job has been really created or not?
    so for that I have used the following command line:
    SQL> SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS';
    SELECT JOB_NAME FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME = 'SCOTT.SPLITSMS'
    ERROR at line 1:
    ORA-00942: table or view does not existYou can use DBA_* views only if the User has been Granted a DBA Privilege.
    how to check my job name from the database...
    what is the command used to check the job_name ????You can use USER_JOBS view to check. But, is it not that you have just created the Job, so you must be knowing it?
    and how can i ensure that my job scheduler is running properly...???If USER_JOBS.FAILURES is Non Zero, that means the Job has encountered a problem that needs to be Investigated. Similarly, the LAST_DATE, LAST_SEC, NEXT_DAY, NEXT_SEC can be used to determine if the Job has been running successfully.
    if you are on 11g, you should consider using DBMS_SCHEDULER.

  • How to run the job using DBMS_SCHEDULER

    How to run the job using DBMS_SCHEDULER
    pleas give some sample Iam very new to DBMS_SCHEDULER

    Hi
    DBMS_SCHEDULER
    In Oracle 10g the DBMS_JOB package is replaced by the DBMS_SCHEDULER package. The DBMS_JOB package is now depricated and in Oracle 10g it's only provided for backward compatibility. From Oracle 10g the DBMS_JOB package should not be used any more, because is could not exist in a future version of Oracle.
    With DBMS_SCHEDULER Oracle procedures and functions can be executed. Also binary and shell-scripts can be scheduled.
    Rights
    If you have DBA rights you can do all the scheduling. For administering job scheduling you need the privileges belonging to the SCHEDULER_ADMIN role. To create and run jobs in your own schedule you need the 'CREATE JOB' privilege.
    With DBMS_JOB you needed to set an initialization parameter to start a job coordinator background process. With Oracle 10g DBMS_SCHEDULER this is not needed any more.
    If you want to user resource plans and/or consumer groups you need to set a system parameter:
    ALTER SYSTEM SET RESOURCE_LIMIT = TRUE;
    Baisc Parts: Job
    A job instructs the scheduler to run a specific program at a specific time on a specific date.
    Programs
    A program contains the code (or reference to the code ) that needs to be run to accomplish a task. It also contains parameters that should be passed to the program at runtime. And it?s an independent object that can referenced by many jobs
    Schedules
    A schedule contains a start date, an optional end date, and repeat interval with these elements; an execution schedule can be calculated.
    Windows
    A window identifies a recurring block of time during which a specific resource plan should be enabled to govern resource allocation for the database.
    Job groups
    A job group is a logical method of classifying jobs with similar characteristics.
    Window groups
    A window groups is a logical method of grouping windows. They simplify the management of windows by allowing the members of the group to be manipulated as one object. Unlike job groups, window groups don?t set default characteristics for windows that belong to the group.
    Using Job Scheduler
    SQL> drop table emp;
    SQL> Create table emp (eno int, esal int);
    SQL > begin
    dbms_scheduler.create_job (
    job_name => 'test_abc',
    job_type => 'PLSQL_BLOCK',
    job_action => 'update emp set esal=esal*10 ;',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=DAILY; INTERVAL=10',
    comments => 'Iam tesing scheduler');
    end;
    PL/SQL procedure successfully completed.
    Verification
    To verify that job was created, the DBA | ALL | USER_SCHEDULER_JOBS view can be queried.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_abc FALSE 0
    Note :
    As you can see from the results, the job was indeed created, but is not enabled because the ENABLE attribute was not explicitly set in the CREATE_JOB procedure.
    Run your job
    SQL> begin
    2 dbms_scheduler.run_job('TEST_abc',TRUE);
    3* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_ABC FALSE 0
    Copying Jobs
    SQL> begin
    2 dbms_scheduler.copy_job('TEST_ABC','NEW_TEST_ABC');
    3 END;
    4 /
    PL/SQL procedure successfully completed. Hope it will help you upto some level..!!
    Regards
    K

  • HOW TO DELETE SCHEDULED.JOBS

    hi.
    i have 4 simple questions.
    1.how to view all procedures name
    2.how to view all scheduled jobs name.
    3.how to delete all scheduled jobs
    4.how to delete sceduled job with with specific name.
    thanks in advance
    regards
    sajid

    Hi,
    1.
    SELECT *
      FROM all_procedures;2.
    SELECT * FROM ALL_SCHEDULER_JOBS;  
    SELECT * FROM ALL_SCHEDULER_PROGRAMS;3. (But I would not do this)
    BEGIN
       FOR rec IN (SELECT job_name
                     FROM user_scheduler_jobs)
       LOOP
          dbms_scheduler.drop_job(rec.job_name);
       END LOOP;
    END;4.
    DBMS_SCHEDULER.DROP_JOB;In general, If you need some dictionary view, but not sure what's it called, query the dictionary itself, Example;
    SELECT *
      FROM DICTIONARY
    WHERE table_name LIKE '%SCHEDU%';Regards
    Peter
    Regards
    Peter

  • How can I kill database connections

    I would like to know how can I kill all the database connexion at the end of an application. I'm using acces
    thx

    use con.close() in a finally statement after your catch blocks that tests whether con equals null. If con != null, then con.close();
    example:
    finally {
              //close the database connection.
              try {
                      if (con != null) con.close();
              catch (SQLException e) {
    }

  • How tto remove the jobs?

    Hi all,
    hope somebody has already faces and given suggestions in this issue.
    anyway i want u people co-operate with me in this issue.
    y'day one of my friend has faced some problem in dba_jobs (i.e)
    he has scheduled one job thru dba_jobs very long back.
    for every ten mins it needs to be scheduled like that.
    when he checked the same on y'day evng at 17.40 it shows job is going til 18.30 then he thought to kill that job but couldn't. so he tried to broke that job and then tried the same but the same prev.result only came. in the meanwhile there were several locks created in his database. then atlast he has set job_queue_process=0; and then remove that job and rescheduled the job is working fine till now. but the things is his seniors wants the root cause of the failure jobs and also in alert it shows that the job_queue_process=0 parameters. so he dont know what to do and how to proceed pls guide ?
    what all are things to be check if the jobs is getting failure?
    how to remove that job without giving trouble to database and changing the job_queue_process?
    pls suggest ..
    and compare the dbs_jobs with dbms_scheduler which one is best ?

    Hi Balamulari
    The following are the steps I follow to kill a job.
    1.First make the job broken
    SQL>exec dbms_job.broken(JobID,true);
    2. See if the job is running
    SQL>select * from dba_jobs_running where job='JobID';
    3. If the job is running you can wait till the job gets completed or if you want to kill the job then find the job's SID and serial#
    SQL>select sid from dba_jobs_running where job='JobID';
    SQL>select serial# from v$session where sid=' XXX';
    SQL>alter system kill session 'sid,serial#';
    If the job does not disappaer from the queue then find the OS SPID and kill it ( kill -9 <SPID>)
    cheers
    APV

  • How to stop backup job on enterprise manager

    Hi
    I have a rman job on enterprise manager which takes backup of all the datafiles everyday.
    How can I temporaraly stop the job and resume later? The job hasnt started yet.
    Database is oracle 10g. operating system is unix
    regards

    If you stop it, it will not run again and you won't be able to reschedule it. Killing sounds like it will solve your problem.
    To kill:
    Once you click on the "Running" link next to the job_name, you should see these two links (the second one may take a few seconds to show up):
    Step: Prebackup
    Step: Backup
    Click on the "Step: Backup" hyperlink. There will be a "Kill Step" button at the top right corner.
    If you don't see it, you can also connect to the database itself and kill the RMAN SIDs. This should show the job's status as "Problems". You can then edit the "Scheduled" job that should have been created.
    As for the run tomorrow, make sure you delete the O/S files created by the killed job if they are still there and run "crosscheck backup" (from RMAN or Grid/Manage Backup). This will make sure RMAN doesn't skip any datafiles at the next run.

  • How to create a job card and how to add waranty card in sales order

    I have one scenario for CS.the scenario is realted to automotive industry. Basically its a trading industry of HCV,MCV,LCV apart from that they will do servicing also. First the customer comes for a service.he is having free services. he will have waranty for spare parts of the vehicle. once he comes for servicing first the executive will take complains from the customer after that a Job card will be issued to the customer. there his chasis no ,engine no and registration no will be there. once enter the chasis no entire customer details has to come. how many free services he is having for how many kilo meters.then job card will go to the spare parts dept.that dept will issue the spare parts.then they will invoice the customer. he will pay the payment.and finally the gate pass will be given to the customer to deliver the vehicle.
    painful area is how to create a job card and how to add waranty in sales order.
    Regards,
    Venkat

    Hi,
    Have u resolved it then Please let me know !!! It is a very interesting problem and owuld like to know the solution...
    Regards
    Krishna

Maybe you are looking for