首页 > 服务器    日期:2022-03-19 / 浏览

杀掉oracle在线用户,在oracle所在服务器上使用root用户执行该脚本
参数说明$1为该oracle用户

复制代码 代码如下:
#!/bin/sh
function _oracleplus(){
su - oracle -c "$oraclehome/bin/sqlplus /nolog" <<EOF
connect / as sysdba;
$1
exit
EOF
}
echo "start select $1 session!!!"
selectUS="select 'alter system kill session '''||sid||','||serial#||''';' from v\$session where username=''$1'';"
_oracleplus "$selectUS" |grep 'alter system' > onlinesession.dmp
echo "start kill $1 session!!!"
cat onlinesession.dmp | while read line;
do
_oracleplus "$line"
done
echo "end kill $1 session!!!"

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章