Thursday, February 6, 2014

How to find and kill the DBMS jobs running


select job_name, session_id, running_instance, elapsed_time, cpu_used
from dba_scheduler_running_jobs;

JOB_NAME SESSION_ID RUNNING_INSTANCE
------------------- ---------- ----------------
JOB_DEL_PROJECTS 67 4

Now you can stop the job using

exec DBMS_SCHEDULER.stop_JOB (job_name => 'JOB_DEL_PROJECTS');

or you can kill the SID

11g RAC: Killing user sessions from different instance



You can be logged onto instance 1 and can kill user sessions for all other instances in the RAC cluster.

ALTER SYSTEM KILL SESSION 'SID, SERIAL#,[@INST_ID]'

The below statement will generate the script which you can run on any instance to kill session from all the instances.

select 'alter system kill session '''||sid||','||serial#||',@'||inst_id||''';' from gv$session where osuser='SCOTT';