ITPub博客

首页 > Linux操作系统 > Linux操作系统 > unix profile idletime

unix profile idletime

原创 Linux操作系统 作者:dbwriter 时间:2011-01-26 18:32:00 0 删除 编辑

参考文章 Script for killing sniped sessions shadow processes [ID 96170.1]

创建 idletime的profile,并修改用户的profile。

例:
alter system set resource_limit = true;
create profile idletime limit idle_time 120;
alter user scott profile idletime;
当设定了如上的profile时,查询 v$session 视图,过了idletime后的session status 列标示为
'sniped'  的。pmon 不会清除 sniped 的进程,使用'alter system kill session' 杀掉session
但session status 标示为 killed ,最终不会清除超过idletime的session。 
需要单独写个脚本利用crontab 来执行此操作
附aix crontab 和脚本
00 * * * * /export/home/oracle/product/10.2.0/db_1/killidle.sh
$ cat /export/home/oracle/product/10.2.0/db_1/killidle.sh
#!/bin/sh
export ORACLE_BASE=/export/home/oracle
export ORACLE_HOME=/export/home/oracle/product/10.2.0/db_1
export ORACLE_SID=demo
export PATH=$ORACLE_HOME/bin:$PATH
tmpfile=/tmp/tmp.$$
sqlplus "noap/uwaysoft2009" << EOF
set feed off;
set pages 9999 lines 170;
spool $tmpfile
select p.spid from v$process p,v$session s
where s.paddr=p.addr
and s.status='SNIPED';
spool off
EOF
for x in `cat $tmpfile | grep "^[0123456789]"`
do
kill -9 $x
done
rm $tmpfile
[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25093763/viewspace-1045215/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-12-16

  • 博文量
    12
  • 访问量
    28537