首页 > Linux操作系统 > Linux操作系统 > 杀掉长期inactive的进程
给大家一个杀掉长期不活动进程的语句
CREATE OR REPLACE PROCEDURE "KILL_SESSION" AS
v_sid number;
v_serial number;
killer varchar2(1000);
CURSOR cursor_session_info is select sid,serial# from v$session where type!='BACKGROUND' and status='INACTIVE' and last_call_et>2700 and username='NACECCMS28';
BEGIN
open cursor_session_info;
loop
fetch cursor_session_info into v_sid,v_serial;
exit when cursor_session_info%notfound;
killer:='alter system disconnect session '''||v_sid||','||v_serial||''' post_transaction immediate';
execute immediate killer;
end loop;
dbms_output.PUT_LINE(cursor_session_info%rowcount||' users with idle_time>2700s have been killed!');
close cursor_session_info;
END;
/
#这样做其实还是治标不治本,最好能够解决连接池自动释放idle进程的问题
#last_call_et指的是空闲空间较长的连接
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16978544/viewspace-691848/,如需转载,请注明出处,否则将追究法律责任。