定时kill长事务
因为ogg抽取进程需要一定的归档,防止归档被删除,所以定时kill长事务,防止抽取进程abend
--kill_long_session.sh
#!/bin/sh
tmpfile0=/oracle/temp/monitor/kill_0.log
tmpfile1=/oracle/temp/monitor/kill_1.log
tmpfile2=/oracle/temp/monitor/kill_2.log
sqlplus / as sysdba <
spool $tmpfile1
set feedback off
select 'kill time:'||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') execute_time from dual;
set line 200
set pages 1000
col username for a15
col command for a70
col machine for a20
col terminal for a20
col program for a20
select /*+rule*/ p.spid,s.sid,s.serial#,s.sql_id,s.username,s.machine,s.terminal,s.program
from v\$process p,v\$session s
where s.paddr=p.addr and s.username<>'SYS' and s.type='USER'
and s.saddr in (select t.ses_addr from v\$transaction t where to_date(t.start_time, 'mm/dd/yy hh24:mi:ss') < sysdate - 5/24);
spool off
EOF
cat $tmpfile1>>$tmpfile0
grep "^[0123456789]" $tmpfile1 |awk '{print $1}'>$tmpfile2
for x in `cat $tmpfile2`
do
kill -9 $x
done
rm $tmpfile1 $tmpfile2
--contab 调度
00 * * * * /oracle/temp/monitor/kill_long_session.sh>>/oracle/temp/monitor/kill_long_session.log
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24996904/viewspace-1178047/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24996904/viewspace-1178047/