殺掉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!!!"
新聞熱點
疑難解答