Killing the Oracle DBMS_JOB

Killing the Oracle DBMS_JOB

Take control of Oracle's queue with a step by step approach to getting rid of those pesky DBMS_JOBs.
Let's face it, Oracle's job scheduling facility is a wonderful tool for scheduling Oracle related jobs without having to maintain a cron job on Unix or an AT job in windows. It is also very robust and reliable. It is that very reliability and robustness that gives many of us our problems.
If you have any form. of jobs running on your system, you will at one time or another come across the issue of a run-away job that just doesn't seem to want to end. Or maybe you will try and shutdown the database only to find out that it is waiting to complete a job. I would like to offer some help in the management of those job queues when they just don't seem to want to end or go away.
A while back I needed to find information on how to clear the job queue for jobs running with no apparent end in sight. Some had hung, while others just were taking a bad access path to data. I needed to bring down these jobs, do a bit of tuning and then restart the jobs. Well, to my amazement, there wasn't very much information out on the web that gave good insight into this process. Basically the method suggested was to first break the job and then issue an ALTER SYTEM KILL SESSION command. This method does not always work and unfortunately--never on my system, for the jobs I had. I then called Oracle support and basically got the same answer as I found out on the web. They did give me one added piece of information. They said, if the ALTER SYSTEM KILL SESSION didn't work, I was supposed to bounce my database in order to bring down the job queue processes. First of all, this wasn't an option and when I did get the opportunity to bounce the database box, many of the jobs seemed to come right back as strong as ever.
Before writing this article I did another quick search on the topic of killing dbms_jobs and to my amazement there still wasn't much good information out there. This is why I want to share my method, so that you won't be stuck up against the wall with this problem and nowhere to turn, as I was.
Viewing Scheduled dbms_jobs
When looking at what jobs have been scheduled, there is really only one view that you need to go to. The dba_jobs view contains all of the information you need, to see what has been scheduled, when they were last run, and if they are currently running. Use the following simple script. to take a look. Bear with me on the sub-select, I will build on this query as we go on in the presentation.

scheduled_dbms_jobs.sql
set linesize 250
col log_user      for a10
col job            for 9999999  head 'Job'
col broken        for a1        head 'B'
col failures      for 99        head "fail"
col last_date      for a18      head 'Last|Date'
col this_date      for a18      head 'This|Date'
col next_date      for a18      head 'Next|Date'
col interval      for 9999.000 head 'Run|Interval'
col what          for a60

select j.log_user,
    j.job,
    j.broken,
    j.failures,
    j.last_date||':'||j.last_sec last_date,
    j.this_date||':'||j.this_sec this_date,
    j.next_date||':'||j.next_sec next_date,
    j.next_date - j.last_date interval,
    j.what
from (select dj.LOG_USER, dj.JOB, dj.BROKEN, dj.FAILURES,
            dj.LAST_DATE, dj.LAST_SEC, dj.THIS_DATE, dj.THIS_SEC,
            dj.NEXT_DATE, dj.NEXT_SEC, dj.INTERVAL, dj.WHAT
        from dba_jobs dj) j;

What Jobs are Actually Running

A simple join to the dba_jobs_running view will give us a good handle on the scheduled jobs that are actually running at this time. This is done by a simple join through the job number. The new column of interest returned here is the sid which is the identifier of the process that is currently executing the job.

running_jobs.sql

set linesize 250
col sid            for 9999    head 'Session|ID'
col log_user        for a10
col job            for 9999999 head 'Job'
col broken          for a1      head 'B'
col failures        for 99      head "fail"
col last_date      for a18      head 'Last|Date'
col this_date      for a18      head 'This|Date'
col next_date      for a18      head 'Next|Date'
col interval        for 9999.000 head 'Run|Interval'
col what            for a60
select j.sid,
        j.log_user,
        j.job,
        j.broken,
        j.failures,
        j.last_date||':'||j.last_sec last_date,
        j.this_date||':'||j.this_sec this_date,
        j.next_date||':'||j.next_sec next_date,
        j.next_date - j.last_date interval,
        j.what
from (select djr.SID,
                  dj.LOG_USER, dj.JOB, dj.BROKEN, dj.FAILURES,
                  dj.LAST_DATE, dj.LAST_SEC, dj.THIS_DATE, dj.THIS_SEC,
                  dj.NEXT_DATE, dj.NEXT_SEC, dj.INTERVAL, dj.WHAT
          from dba_jobs dj, dba_jobs_running djr
        where dj.job = djr.job ) j;

What Sessions are Running the Jobs

Now that we have determined which jobs are currently running, we need to find which Oracle session and operating system process is accessing them. This is done through first joining v$process to v$session by way of paddr and addr which is the address of the processs that owns the sessions, and then joining the results back to the jobs running through the sid value. The new columns returned in our query are spid which is the operating system process identifier and serial# which is the session serial number.

session_jobs.sql

set linesize 250
col sid          for 9999    head 'Session|ID'
col spid                      head 'O/S|Process|ID'
col serial#      for 9999999 head 'Session|Serial#'
col log_user      for a10
col job          for 9999999 head 'Job'
col broken        for a1      head 'B'
col failures      for 99      head "fail"
col last_date    for a18      head 'Last|Date'
col this_date    for a18      head 'This|Date'
col next_date    for a18      head 'Next|Date'
col interval      for 9999.000 head 'Run|Interval'
col what          for a60
select j.sid,
s.spid,
s.serial#,
      j.log_user,
      j.job,
      j.broken,
      j.failures,
      j.last_date||':'||j.last_sec last_date,
      j.this_date||':'||j.this_sec this_date,
      j.next_date||':'||j.next_sec next_date,
      j.next_date - j.last_date interval,
      j.what
from (select djr.SID,
            dj.LOG_USER, dj.JOB, dj.BROKEN, dj.FAILURES,
            dj.LAST_DATE, dj.LAST_SEC, dj.THIS_DATE, dj.THIS_SEC,
            dj.NEXT_DATE, dj.NEXT_SEC, dj.INTERVAL, dj.WHAT
        from dba_jobs dj, dba_jobs_running djr
      where dj.job = djr.job ) j,
    (select p.spid, s.sid, s.serial#
          from v$process p, v$session s
        where p.addr = s.paddr ) s
where j.sid = s.sid;

Now that we have a good handle on how we can look at the jobs and the key columns involved, let's go through the steps needed to bring down a job. The following is a 5 to 11 step process that should solve all of your problems.
Bringing Down a DBMS_JOB

1. Find the Job You Want to Bring Down

In order to do anything you first need to find the job that is giving you a headache. Go ahead and run the running_jobs.sql. This will give you the prime information, job, sid, serial#, and spid, for the following actions in bringing down the job.

2. Mark the DBMS_JOB as Broken

Use the following command for the job that you have to deal with.

SQL> EXEC DBMS_JOB.BROKEN(job#,TRUE);

All this command does is mark the job so that if we get it to stop, it won't start again. Let's make one thing perfectly clear, after executing this command the job is still running.

As a side note, if you are trying to shut down a database with jobs that run throughout the day, they may hinder your attempts to bring down the database cleanly. This is a wonderful command to make sure no jobs are executing during the shutdown process. Just be aware that you will need to mark the jobs as unbroken when the database comes back up, more on that later.

3. Kill the Oracle Session

Since the job is still running and it isn't going to end soon, you will need to kill the Oracle session that is executing the job. Use the following command for to kill the job.

ALTER SYSTEM KILL SESSION 'sid,serial#';

4. Kill the O/S Process

More often than not the previous step will still leave the job attached to the database and still running. When this happens you will need to go out to the operating system level and get rid of the process that has spawned from the running job. In order to do this you must login to the database box and issue the following command, depending on the type of operating system you have.

For Windows, at the DOS Prompt: orakill sid spid

For UNIX at the command line> kill '9 spid

The orakill is an Oracle command, while kill is a Unix command.

5. Check if the Job is Still Running

Re-run the session_jobs.sql script. to see if you have gotten rid of the job. If you have there is no reason to go further. Usually steps 1 through 4 will be sufficient to get rid of a job but when the job is running wild you will have to continue with steps 6 through 11 which describes a process for bouncing the job queue process.

6. Determine the Current Number of Job Queue Processes

SQL> col value for a10
SQL> select name,value from v$parameter where name = 'job_queue_processes';

7. Alter the Job Queue to Zero

SQL> ALTER SYSTEM SET job_queue_processes = 0;

This will bring down the entire job queue processes.

8. Validate that No Processes are Using the Job Queue

Re-run the session_jobs.sql script. to see if any jobs are still running. Since we have given a hard stop to the job queue and issued the kill commands, you can now wait until no more jobs are running. After all the jobs have quit running, you can do whatever maintenance or tuning you need to do before proceeding.

9. Mark the DBMS_JOB as Not Broken
You can now reset the broken job to not broken so they can run again. Just issue the command.

SQL>EXEC DBMS_JOB.BROKEN(job#,FALSE):

10. Alter the Job Queue to Original Value
Set the job queue to its' original value so that the jobs can run again.

ALTER SYSTEM SET job_queue_processes = original_value;

11. Validate that DBMS_JOB Is Running
To make sure everything is back to normal, re-run the above scripts to validate that jobs are scheduled, not broken, and are executing with the next and last dates columns changing.

Oracle have given us a great tool for scheduling activities within the database. As with many things inside the database, not everything goes as planned, nor are we given adequate tools to fix some of the problems we encounter. With the eleven steps outlined here, hopefully you will have increased your arsenal to handle those run away jobs that have given the best of us a few tense moments.
--------------------------------------------------------------------------------------------------------------------------
注意:第四步 删除操作系统层次的进程或线程操作,Oracle在Linux/Unix中后台进程是以进程方式运作,在Windows系列操作系统中是以线程方式运作。
对于Windows,启动命令提示符:
orakill sid spid
其中sid是数据库实例的名称,而不是前面脚本中查出来的sid。
可以通过一下命令来得到:
select name from v$database;
select instance_name from v$instance;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10640532/viewspace-567127/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10640532/viewspace-567127/

【毕设全程指导】基于YOLOv8的包装商品检测与可视化系统(SKU110K实战) 本文介绍了一个基于YOLOv8的包装商品检测与可视化系统毕业设计方案。项目采用SKU110K数据集,通过CSV转TXT格式转换适配YOLO模型训练,包含详细的环境搭建、模型配置和训练流程。系统实现了包装商品的自动化检测,并开发了Tkinter可视化界面进行交互式检测展示。该方案结合产业应用需求与技术深度,既具备实用价值,又能充分展示学生的技术能力,适合作为计算机视觉相关专业的毕业设计选题。整个项目从数据准备到界面开发完整覆盖,帮助学生系统掌握目标检测项目的完整实现流程。 阅读详情

相关推荐

vCenter6.7证书过期导致503报错的全面修复指南:从STS证书更新到SSL信任修复

本文详细解析了VMware vCenter 6.7因STS证书过期导致503服务不可用错误的根本原因,并提供了从诊断、更新STS证书到修复SSL信任链的完整解决方案。通过命令行工具检查证书状态,使用官方脚本更新过期STS证书,并利用lsdoctor工具修复深层SSL信任问题,最终指导用户使用certificate-manager彻底重置所有证书,帮助管理员快速恢复vCenter服务。

pz890123的博客 1293

如何停止正在运行的job(解决job不能删除或修改的问题)

正在运行的job 删除或修改是不行的,只能 kill  process  /  kill  session。 --1.先查一下正在运行的job select *from dba_jobs_running; --2.查找到session select a.spid, b.SID, b.SERIAL#   from v$process a, v$session b  where a.add

关注系统性能调优 1万+

软件工程期末知识点总结【超详细】

生命周期模型(过程模型):瀑布模型、快速原型模型、增量模型、螺旋模型、喷泉模型。2、实体联系图:1、数据对象2、属性3、联系(1:1、1:N、M:N)3、语句覆盖 就是设计足够的调试用例,使得程序中的每个语句至少执行一次。 5、判定覆盖就是设计足够的测试用例,使得程序中每个判定的取“真”分支和取“假”分支至少都执行一次,判定覆盖又称分支覆盖 6、条件覆盖就是设计足够的测试用例,使得程序判定中的每个条件能获得各种可能的结果。7、软件开发时期通常分成4个阶段:总体设计、详细设计、编码和单元测试、综合测试。

这个人好有趣....hh 1万+

oracle创建job和删除job

oracle创建job和删除job

secret安静 2万+

从Podfile到分享成功:ShareSDK小红书模块集成全流程实战(附视频分享代码)

本文详细介绍了iOS应用如何通过ShareSDK集成小红书分享功能的全流程,包括环境配置、SDK初始化、图片和视频分享实现,以及常见问题排查和性能优化策略。特别针对视频分享这一高频需求场景,提供了完整的代码示例和实战技巧,帮助开发者快速实现社交分享功能。

weixin_42540248的博客 226

《AFSim 2.9中文参考手册》

本栏目将对《AFSim 2.9中文参考手册》进行持续更新,欢迎关注交流!对本文或者AFSIM相关内容感兴趣的朋友,可私心联系作者。《AFSim 2.9中文参考手册》内容概览。

henggesim的博客 1万+

数据泵重启报错ORA-39004: invalid state

停止作业是一定要使用STOP_JOB=IMMEDIATE这个命令,否则数据泵作业的状态为"STOP PENDING"时,表示作业正在等待停止。这意味着在之前的操作中,作业已经被停止,但还没有完全停止。当作业处于"STOP PENDING"时,执行STOP_JOB=IMMEDIATE后,看作业状态,然后执行start_job即可。暂停作业时使用了stop_job命令,state=STOP PENDING。后来处理报错后重新启动job。执行START_JOB报错。

qq_52254886的博客 458

论文阅读:Visual Relationship Detection with Language Priors

Visual Relationship Detection with Language Priors(ECCV2016) 文章   尽管大多数的relationship并不常见,但是它们的object和predicate却更频繁地独立出现。paper用这个insight分别独立训练训练object和predicate的模型,然后再进行组合来预测relationship。Visual relatio...

Kivee的博客 2877

oracle停止当前运行的JOB或kill会话

在Oracle中,您可以使用DBA_SCHEDULER_JOBS视图来查找当前正在运行的作业(job),并使用DBMS_SCHEDULER.STOP_JOB过程来停止它们。上面的SQL查询会列出所有当前状态为RUNNING的作业,即正在运行的作业。要停止这些作业,可以编写一个PL/SQL块来遍历这些作业并停止它们。

狗剩儿的记忆博客 2515

UFAST车道线检测 Ultra-Fast-Lane-Detection 从环境搭建到复现完成(一)

UFAST车道线检测 Ultra-Fast-Lane-Detection 从环境搭建到复现完成(一)

m0_46364958的博客 4345

如何利用Dpabi,AFNI,FSL软件计算种子点的功能连接?

fsl_glm 得到的是线性回归系数(beta coefficient),由于在自变量和因变量标准化(均值为 0,标准差为 1)的情况下,简单线性回归的回归系数和皮尔逊相关系数是相同的,因此这是一种间接的方法。(3)上一步得到的 PCC.nii.gz 文件是 Harvard-Oxford 概率模板中的后扣带回,每个体素中的数值(1-100)表示该体素属于 PCC 的概率,反映 PCC 在不同被试中的变异大小,也表示我们对于某个体素属于PCC 的信心。接下来,我们来聊聊功能连接在数据处理里的具体应用。

从事脑科学核磁共振方法学研究,在Nature communications等权威期刊发表研究论文,熟练掌握磁共振处理方法和统计学方法,欢迎大家和我交流。 7841

Killing DBMS_JOB

To check scheduled job: scheduled_dbms_jobs.sql set line 200 pages 200col log_user for a10col job for 9999999 he...

cuichao112233的博客 130

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Oracle中job的使用详解

Oracle中job的使用详解 --1.plsql中学习job    --学习job   --建表   create table test_job(para_date date);   commit;      insert into test_job values(sysdate);   commit;    select * from test_job;    --建立

北极星的专栏 7294

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

oracle job使用详解及job不运行的检查方法

每天1点执行的oracle JOB样例DECLAREX NUMBER;BEGINSYS.DBMS_JOB.SUBMIT( job => X,what => 'ETL_RUN_D_Date;',next_date =&...

csdn6538954的博客 514

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

oracle 杀掉正在运行中的job

问题处理:有定时job执行完毕后,却一直是running状态: 过程: 查看正在运行中的job以及对应的sid号: select * from dba_jobs_running; 查询对应的session信息: select sid,serial# from v$session where sid in('458'); 杀死对应的session: alter system kill session '458,16551'; 补充: 可执行以下命令直接将该job置为borken,不再运行: EXEC D

a1264716408的博客 2004

oracle 杀job进程,Oracle杀死job的方法&杀死job相关进程方法

环境:Oracle11.2.0.41、判断job是否卡死用PL/SQL Developer看到job是否完成,查看job属性中LAST DATE是否变成第二天的执行时间。如果没变,说明job没有执行结束。也可以用下面的语句查询:select * from dba_jobs_running where job='job号';用这个语句可以查询执行job的sid列(会话编号)的值,这个值是杀死job...

weixin_39820173的博客 1439

oracle 如何kill,ORACLE 如何kill掉一直运行的job

今天发现数据库一个JOB一直在执行,都执行了5个小时还在执行,所以想办法给删除掉系统环境:ORACLE 10GAIX操作系统操作步骤如下:第一步、查询出来那个job在运行,找个对应的SID字段 1、select * from dba_jobs_running--找到job对应的sid 第二部、通过以下语句查询出来SID对应的SPID, 其中SCHEMANAME='#username#'是...

weixin_34364310的博客 1116

ORACLE—006:移除和停止JOB

一般来说都是通过sql来删除或者停止某个job。移除JOB:remove停止JOB:broken首先通过 select * from user_jobs;查找出JOB的ID,然后调用dbms_job.broken或dbms_job.remove进行移除和停止。sql如下。以移除一个job为例。1、通过JOB的what值来查找job,并移除。declare  job number;  v_count

杨友山 5810

Oracle 创建、暂停、更改、删除 定时任务job

Oracle 定时任务 job

_修铁路的、的博客 4万+

ORACLE删除正在执行的定时任务

select * from dba_jobs_running --假定jobno是224 begin --先执行这个 ,停掉定时任务 dbms_job.broken(224, true, sysdate); commit; end; select * from dba_jobs_running where job='224'; select * from v$session ...

qq_42332498的博客 1474

oracle 强制停止正在运行的job

//获取正在运行的jobselect * from dba_jobs_running;//获取正在运行job(24)的详细信息select b.SID,b.SERIAL#,c.SPIDfrom dba_jobs_running a,v$session b,v$process cwhere a.sid = b.sid and b.PADDR = c.ADDR and a.job=24//杀死jobA...

weixin_39093695的博客 8719

删除job

1、查看所有job;select * from dba_jobs;2、查看正在运行的job;select * from dba_jobs_running;3、根据sid查出对应的session;select SID,SERIAL# from V$Session where SID=&SID;4、kill对应的session;alter system kill session &SID,&

liuxuefengchina的专栏 679
上一篇: dedicated模式下ORA_SNNN _SID ORA_DNNN_SID进程
下一篇: 常用Linux命令—TOP
cuicuntu1021
博客等级 码龄11年 1粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值