Search This Blog

Wednesday, 9 March 2016

Oracle Start&Stop script

#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

# Source function library.

. /etc/rc.d/init.d/functions

ORACLE_HOME=/app/oracle/product/11.2.0/dbhome_1
ORACLE_OWNER=oracle

if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi

case "$1"  in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
       echo -n $"Starting Oracle DB:"
        su - $ORACLE_OWNER  -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
        echo "Oracle started"
        echo   `emctl start dbconsole`
        ;;
    'stop')
        # Stop the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
        su - $ORACLE_OWNER
        echo   `emctl stop dbconsole`
       echo   `$ORACLE_HOME/bin/dbshut $ORACLE_HOME`
   
       echo "Done"
        ;;
*)
echo $"Usage: $0 {start|stop}"
esac

No comments:

Post a Comment