Shell實(shí)現(xiàn)的Oracle啟動(dòng)腳本分享
Usage: sh oracled [start|stop|restart] SIDs 其中SIDs是數(shù)據(jù)庫(kù)名,多個(gè)名稱(chēng)之間用逗號(hào)分隔。缺省的操作是 restart ,也可以指定需要進(jìn)行的操作( start | stop | restart )
#!/bin/sh
cmdname="restart"
# get oracle sid information from env by default.
oracleSID=${ORACLE_SID}
env_oracleSID=${ORACLE_SID}
function echohelp(){
echo "******oracled Tool Helper******"
echo "Usage:sh oracled [start|stop|restart] SIDs"
echo "SIDs : seperated by comma"
exit 5
}
function startoracle(){
echo "begin to start oracle ..."
lsnrctl start
for curSID in `echo ${oracleSID} | awk 'BEGIN {RS=","}{ORS="\n"}{print $1}'` ; do
if [ "x${curSID}" = "x" ] ; then
continue;
fi
export ORACLE_SID=${curSID}
sqlplus /nolog <<EOF
connect /as sysdba
startup
exit
exit
EOF
echo "oracle DB [${curSID}] started OK."
done
}
function stoporacle(){
echo "begin to stop oracle ..."
for curSID in `echo ${oracleSID} | awk 'BEGIN {RS=","}{ORS="\n"}{print $1}'` ; do
if [ "x${curSID}" = "x" ] ; then
continue;
fi
export ORACLE_SID=${curSID}
sqlplus /nolog <<EOF
connect /as sysdba
shutdown immediate
exit
exit
EOF
echo "oracle DB [${curSID}] stopped OK."
done
lsnrctl stop
}
function restartoracle(){
stoporacle
startoracle
}
if [ $# -lt 1 ] ; then
echohelp
fi
until [ $# -eq 0 ]
do
tmpVOrg=$1
tmpV=`echo "${tmpVOrg}" | awk '{printf "%s",$1}' | tr '[A-Z]' '[a-z]'`
if [ $tmpV = "start" -o $tmpV = "restart" -o $tmpV = "stop" ] ; then
cmdname=${tmpV}
elif [ $tmpV = "--help" -o $tmpV = "-h" ] ; then
echohelp
else
oracleSID=$tmpVOrg
fi
shift
done
if [ "x${cmdname}" = "x" ] ; then
echohelp
fi
${cmdname}oracle
export ORACLE_SID=${env_oracleSID}
相關(guān)文章
shell 字符串操作(長(zhǎng)度,查找,替換)詳解
在做shell批處理程序時(shí)候,經(jīng)常會(huì)涉及到字符串相關(guān)操作。有很多命令語(yǔ)句,如:awk,sed都可以做字符串各種操作。其實(shí)shell內(nèi)置一系列操作符號(hào),可以達(dá)到類(lèi)似效果,大家知道,使用內(nèi)部操作符會(huì)省略啟動(dòng)外部程序等時(shí)間,因此速度會(huì)非常的快2012-09-09unix編程創(chuàng)建前綴固定的臨時(shí)文件代碼分享
unix編程創(chuàng)建一個(gè)前綴固定的臨時(shí)文件,實(shí)現(xiàn)功能:創(chuàng)建一個(gè)臨時(shí)文件,并返回其文件描述符2013-12-12Shell中if的基本語(yǔ)法和常見(jiàn)判斷用法
這篇文章主要介紹了Shell中if的基本語(yǔ)法和常見(jiàn)判斷用法,本文講解了if的基本語(yǔ)法、對(duì)字符串的判斷、對(duì)數(shù)字的判斷、對(duì)文件屬性的判斷、邏輯判斷等內(nèi)容,需要的朋友可以參考下2015-06-06linux 中open()函數(shù)詳解及簡(jiǎn)單實(shí)例
這篇文章主要介紹了linux 中open()函數(shù)詳解及簡(jiǎn)單實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-04-04Shell位置變量&預(yù)定義變量的實(shí)現(xiàn)
Shell位置變量和預(yù)定義變量是Shell腳本編程中非常重要的概念,本文主要介紹了Shell位置變量&預(yù)定義變量的實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下2023-12-12shell中嵌套執(zhí)行expect命令實(shí)例
這篇文章主要介紹了shell中嵌套執(zhí)行expect命令實(shí)例,一直都想把expect的操作寫(xiě)到bash腳本里,這樣就不用我再寫(xiě)兩個(gè)腳本來(lái)執(zhí)行了,需要的朋友可以參考下2014-12-12