Shell-implemented Oracle startup script sharing _linux Shell

Source: Internet
Author: User
Tags sqlplus

Usage:sh oracled [Start|stop|restart] SIDs where SIDs is the database name and multiple names are separated by commas. The default action is restart, or you can specify the action you want to take (start | Stop | Restart)

Copy Code code as follows:

#!/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 '; Todo
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 '; Todo
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]
Todo
Tmpvorg=$1
Tmpv= ' echo "${tmpvorg}" | awk ' {printf '%s ', $} ' | 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}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.