-
Notifications
You must be signed in to change notification settings - Fork 2
/
kill_job.sql
47 lines (44 loc) · 1.11 KB
/
kill_job.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
begin
sys.dbms_ijob.broken(2364940, TRUE);
sys.dbms_ijob.remove(2364940);
commit;
end;
*/
begin
for c in
(
select
j.job, s.inst_id, p.spid
from
sys.job$ j, gv$lock l, gv$session s, gv$process p
where
l.type = 'JQ' and j.job (+)= l.id2
and s.inst_id = l.inst_id and s.sid = l.sid
and p.inst_id = l.inst_id and p.addr = s.paddr
and j.what like '%JOB_NAME%'
)
loop
dbms_output.put_line(c.inst_id || ' kill -9 ' || c.job);
sys.dbms_ijob.broken(c.job,TRUE);
sys.dbms_ijob.remove(c.job);
commit;
end loop;
end;
declare
job number;
next_date date;
inst_id number;
spid number;
begin
select job, next_date into job, next_date from dba_jobs where upper(what) like '%JOB_NAME%';
if next_date < sysdate then
select l.inst_id, p.spid into inst_id, spid from gv$lock l, gv$session s, gv$process p
where l.type = 'JQ' and l.id2 = job
and s.inst_id = l.inst_id and s.sid = l.sid
and p.inst_id = s.inst_id and p.addr = s.paddr;
dbms_output.put_line(inst_id || ', kill -9 ' || spid);
sys.dbms_ijob.next_date(job,next_date+1);
commit;
end if;
end;