Subscribe YouTube Channel For More Live Tutorials

How to find long running jobs

The following script helps to find the current long running Active jobs in Oracle Database. In this script , we use views such as

gv$session

gv$process

gv$Instance

In case , to find including Inactive then change or remove  "and b.status='ACTIVE' to and b.status in ('ACTIVE','INACTIVE')

prompt long running job
prompt '----------------------------'
col INSTANCE_NAME format a10
col username format a15
col module format a30
col machine format a15
col sql_address format a20
col last_call format a10
set linesize 230;
select b.sql_id, a.instance_name,b.username,b.sid,b.serial#,c.spid,b.process os_process_id,
b.machine,
b.module,
--b.event,
--b.sql_address,
floor(b.last_call_et/3600) ||':'|| floor(mod(b.last_call_et,3600)/60) ||':'|| mod(b.last_call_et,60) Last_Call
from gv$instance a, gv$session b, gv$process c
where a.instance_number = b.inst_id
and b.status='ACTIVE'
and b.last_call_et > 10
and b.username is not null
and b.machine is not null
and b.program not like 'rman%'
and b.program not like '%(P%'
and b.type != 'BACKGROUND'
and b.sql_address != '00'
and b.paddr = c.addr
and b.inst_id = c.inst_id
order by last_call_et desc
/