脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|shell|

服务器之家 - 脚本之家 - shell - 杀掉oracle在线用户脚本分享

杀掉oracle在线用户脚本分享

2022-12-29 12:38脚本之家 shell

这篇文章主要介绍了杀掉oracle在线用户脚本,需要的朋友可以参考下

杀掉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!!!"

 

延伸 · 阅读

精彩推荐