- #!/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!!!"
- #该片段来自于http://www.codesnippet.cn/detail/131120137124.html
来源: http://www.codesnippet.cn/detail/131120137124.html