There is no procedure within the dbms_job package to stop a running job.
You will need to determine which Oracle session and process is associated with this running job and then kill it.

You can run the following query to see job processes:

Find the session id for the running job from dba_jobs_running:
select sid, job, instance from dba_jobs_running where job=&job_id;

Find the OS process id for the session id under which job is running :

set linesize 120
set pagesize 120
column spid heading 'OSpid' format a8
column pid heading 'Orapid' format 999999
column sid heading 'Sess id' format 99999
column serial# heading 'Serial#' format 999999
column status heading 'Status' format a8
column pga_alloc_mem heading 'PGA alloc'
column username heading 'oracleuser' format a12
column osuser heading 'OS user' format a12
column program heading 'Program' format a28
SELECT
p.spid,
p.pid,
s.sid,
s.serial#,
s.status,
p.pga_alloc_mem,
s.username,
s.osuser,
s.program
FROM
v$process p,
v$session s
WHERE s.paddr(+) = p.addr
AND s.sid=&session_id
Order by p.pga_alloc_mem desc;

Then issue the following with the appropriate sid and serial# for that process to kill the job:

ALTER SYSTEM KILL SESSION 'sid,serial#';

Bringing Down a DBMS_JOB 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 above query. This will give you the basic information, job, sid, serial#, and spid, for the following actions to bring down the job.

2. Mark the DBMS_JOB job as broken
Use the following command for the job that you have to deal with.

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 command prompt:

C:\> orakill <sid> <spid>

For UNIX at the command line:

$ kill -9 spid

Note that 'orakill' is an Oracle command, while 'kill' is a Unix command.

5. Remove the BROKEN status of the DBMS_JOB job:

EXEC DBMS_JOB.BROKEN(job#,FALSE);

 

It should be noted that DBMS_JOB has been retained in later versions of Oracle mainly for backward compatibility. It is highly recommended to migrate from DBMS_JOB to DBMS_SCHEDULER which is more powerful and flexible. To convert the jobs from DBMS_JOB to DBMS_SCHEDULER, the document IF: An Example to Convert from DBMS_JOB Jobs to DBMS_SCHEDULER Jobs (Doc ID 2117140.1) may be used.
 
 
####################################

How to disable an entry from DBMS_SCHEDULER?

SOLUTION

Use the DISABLE procedure to disable a job from the scheduler queue.

DBMS_SCHEDULER.DISABLE ( name IN VARCHAR2, force IN BOOLEAN DEFAULT FALSE);

Parameter Description:

name -  the name of the object being disabled; can be a comma-delimited list

force - whether to ignore dependencies

Examples:

SQL> execute dbms_scheduler.disable('AUTO_SPACE_ADVISOR_JOB');
SQL> execute dbms_scheduler.disable('job1, job2, sys.jobclass1');
 
########sample 3:
Disable database jobs (DBMS_SCHEDULER , AUTOTASKS and DBMS_JOBS) before upgrade (文档 ID 1614385.1) 转到底部

修改时间: 2018-8-4 类型: HOWTO

In this Document

  Goal
  Solution
  References

APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.2.0.4 and later
Information in this document applies to any platform.
*** checked for relevance on 24-Nov-2015 ***

GOAL

How to disable database jobs ( DBMS_SCHEDULER , AUTOTASKS and DBMS_JOBS)before upgrade from 11.2.0.3 to 11.2.0.4?

SOLUTION

Since you are on a version 11gR2 then by setting the parameter job_queue_processes to 0 all job processes are stopped, 
which means that DBMS_SCHEDULER jobs, autotask jobs and DBMS_JOB jobs cannot run. When using previous versions only DBMS_JOB jobs were disabled after changing job_queue_processes to 0.

SQL> show parameter job_queue_processes
SQL> alter system set job_queue_processes=0 scope=both;

For more information please check the following :-

http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams112.htm#REFRN10077

However in the case of upgrade , since this violates the utlu112i.sql, then we should use another workaround

1) to disable each job using dbms_scheduler.disable procedure

example :-

SQL>exec DBMS_SCHEDULER.DISABLE('');

And to enable , please do :-

SQL>exec DBMS_SCHEDULER.ENABLE('');

2) to disable all the automated tasks , please do

SQL> EXECUTE DBMS_AUTO_TASK_ADMIN.DISABLE;

And to enable them

SQL> EXECUTE DBMS_AUTO_TASK_ADMIN.ENABLE;

Note: to disable or enable a specific auto task , please use :

SQL>exec DBMS_AUTO_TASK_ADMIN.DISABLE('<client name>' , null, null);
SQL>exec DBMS_AUTO_TASK_ADMIN.ENABLE('<client name>' , null, null);

Where the <client name> can be obtained from the output of

select client_name from DBA_AUTOTASK_CLIENT;

Note: Most important , if you will use these workaround , please test it first on a test server and test enabling them again

3) To disable jobs created via DBMS_JOBS , please run:-

SQL> EXEC DBMS_JOB.BROKEN (<job_id> , TRUE,SYSDATE);

转 How To Stop A Running Job Using DBMS_JOB的更多相关文章

  1. Oracle 中的作业队列和队列调度

    一,启动执行作业的进程       在 Oracle 中,是使用 “作业队列协调进程(CJQ0)” 这个协调数据库实例的作业队列的后台进程,来监视作业队列中的作业表(JOB$),并启动作业队列进程(J ...

  2. Oracle 10.2.0.5升级至11.2.0.4

    参照MOS 官方文档Complete Checklist for Manual Upgrade to Oracle Database 11gR2 (11.2) (Doc ID 837570.1)一.升 ...

  3. Crystal Clear Applied: The Seven Properties of Running an Agile Project (转载)

    作者Alistair Cockburn, Crystal Clear的7个成功要素,写得挺好. 敏捷方法的关注点,大家可以参考,太激动所以转载了. 原文:http://www.informit.com ...

  4. Running Dubbo On Spring Boot

    Dubbo(http://dubbo.io/) 是阿里的开源的一款分布式服务框架.而Spring Boot则是Spring社区这两年致力于打造的简化Java配置的微服务框架. 利用他们各自优势,配置到 ...

  5. Android PopupWindow Dialog 关于 is your activity running 崩溃详解

    Android PopupWindow Dialog 关于 is your activity running 崩溃详解 [TOC] 起因 对于 PopupWindow Dialog 需要 Activi ...

  6. IntelliJ运行下载的Servlet时报错 Error running Tomcat 8.5.8: Unable to open debugger port (127.0.0.1:49551): java.net.SocketException

    学习Java Servlet时,从Wrox上下载了示例代码,准备run/debug时发现以下错误: Error running Tomcat 8.5.8: Unable to open debugge ...

  7. teamviewer "TeamViewer Daemon is not running

    执行下面的命令问题解决: # teamviewer --daemon enable enable Sat Jan :: CST Action: Installing daemon () for 'up ...

  8. mysql 有报错  ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists

    sh-4.1# /etc/init.d/mysqld status ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql ...

  9. Errors occurred during the build. Errors running builder 'JavaScript Validator' on project

    1.问题:Errors occurred during the build. Errors running builder 'JavaScript Validator' on project 2.解决 ...

随机推荐

  1. 浅谈android代码保护技术_加固

    可看原文: http://www.cnblogs.com/jiaoxiake/p/6536824.html 导语 我们知道Android中的反编译工作越来越让人操作熟练,我们辛苦的开发出一个apk,结 ...

  2. 【转】Android android listview的HeadView左右切换图片(仿新浪,网易,百度等切换图片)

    首先我们还是看一些示例:(网易,新浪,百度)      下面我简单的介绍下实现方法:其实就是listview addHeaderView.只不过这个view是一个可以切换图片的view,至于这个vie ...

  3. C# 判断一个数是不是奇数/偶数

    一般普通版: private bool IsOdd(int num) { ) == ; } 通过判断取余 现在升级版: private bool IsOdd(int num) { ) == ; } 通 ...

  4. 6步完成压力测试工具Locust部署和使用

    1,准备安装python,安装过程略 已安装的,查看安装目录: cmd输入where Python 2,pip安装locust 1.进入python所在目录,如果没有配置环境变量,需要进入到C:\Us ...

  5. ubuntu14.04,安装Gnome 15.10 (桌面)

    Linux:ubuntu14.04 Gnome:15.10 更新最新版Gnome的一个好处:更新了ubuntu的软件源,我们可以使用ubuntu的软件中心获取更多需要的软件!! ubuntu默认的桌面 ...

  6. 【转】OracleOraDb11g_home1TNSListener服务启动后又停止了

    源地址:https://www.cnblogs.com/Asa-Zhu/p/3819605.html 一.错误描述 登陆PL/SQL Developer登陆本地数据库时先报没有监听程序,查看服务发现O ...

  7. loj #6013. 「网络流 24 题」负载平衡

    #6013. 「网络流 24 题」负载平衡 题目描述 G 公司有 n nn 个沿铁路运输线环形排列的仓库,每个仓库存储的货物数量不等.如何用最少搬运量可以使 n nn 个仓库的库存数量相同.搬运货物时 ...

  8. 图层锁定vlisp函数高版本图元自动淡色显示

    (defun c:tt(/ obj) (sk_layerLock (getvar "clayer") nil) (princ) ) ;;;name:sk_layerLock ;;; ...

  9. 搭建 docker + nginx + keepalived 实现Web应用的高可用(亲测)

    1. 环境准备     下载 VMware : https://www.vmware.com/go/getplayer-win        下载 Centos : https://mirrors.a ...

  10. Georgia and Bob POJ - 1704 阶梯Nim

    $ \color{#0066ff}{ 题目描述 }$ Georgia and Bob decide to play a self-invented game. They draw a row of g ...