Linx 下oracle 数据库启动停止脚本程序
说明:linux下oracle 数据库涉及切换用户,又要执行命令中参数可以参考如下格式:
su – oracle – c "sqlplus '/ as sysdba'"<<!
startup
exit
!
或者
su – oracle –c "sqlplus '/ as sysdba' << !
startup
exit
! "
或者------10G或者以后版本可以省略sqlplus 后面引号,即:
su – oracle – c "sqlplus / as sysdba" <<!
startup
exit
!
##############Oracle 不同版本启动数据库命令###########
#!/bin/sh
ORACLE_SID=$1
LISTENER=$2
export ORACLE_SID
# The nether lines for Oracle Version 9 or Later
su - oracle -c "sqlplus '/ as sysdba'"<<!
startup
exit
!
# The nether lines for Oracle Version 8 or Older
su - oracle -c "svrmgrl" <<!
connect internal
startup
exit
!
# start Oracle listener
lsnrctl start $LISTENER
##############Oracle 不同版本强制停止命令汇总###########
#!/bin/sh
export ORACLE_SID=$1
LISTENER=$2
#Kill Oracle Listener
LSNR_PID=`ps -ef| grep tnslsnr|grep $LISTENER|grep -v grep|awk -F" " '{print $2}'`
if [ EMPTY"$LSNR_PID = EMPTY ]
then
echo "Not found listener process <tnslsnr>!"
else
echo "Kill oracle listener process <"$LSNR_PID">."
kill -9 $LSNR_PID
fi
#The nether lines for Oracle Version 9 or Later
su - oracle -c "sqlplus '/ as sysdba'" <<!
shutdown abort
exit
!
#The nether lines for Oracle Version 8 or older
su - oracle -c "svrmgrl" <<!
connect internal
shutdown abort
exit
!
##############Oracle 不同版本正常停止###########
#!/bin/sh
export ORACLE_SID=$1
LISTENER=$2
# stop Oracle listener
lsnrctl stop $LISTENER
# The nether lines for Oracle Version 9 or Later
su - oracle -c "sqlplus '/ as sysdba'"<<!
shutdown immediate
exit
!
# The nether lines for Oracle Version 8 or Older
su - oracle -c "svrmgrl "<<!
connect internal
shutdown immediate
exit
!
附加:
附加:su – oracle –c "sqlplus '/ as sysdba'" <<!
host sleep 5;
execute dbms_lock.sleep(5);
shutdown immediate;
exit!
转载于:https://blog.51cto.com/wscyza/940800