#!/usr/bin/ksh
#
#
# set -x
##startdb.ksh
# grep process id for oracle instance and listener
orapid=`ps -ef | grep -v grep | grep oracle | grep ora_ | grep _$ORACLE_SID | awk '{print $2}' | head -1`
lsnrpid=`ps -ef | grep -v grep | grep oracle | grep LISTENER | awk '{print $2}' | head -1`
empid=`ps -ef | grep -v grep | grep oracle | grep LOCAL=NO | grep oracle$ORACLE_SID | awk '{print $2}' | head -1`
isqlpid=`ps -ef | grep -v grep | grep oracle | grep Doracle | grep Djava.awt.headless | awk '{print $2}' | head -1` #
# start oracle instance
if [ "$orapid" -eq "" ]; then
echo "Starting Oracle instance..."
sqlplus /nolog << !
connect /as sysdba
startup
exit
!
else
echo "Oracle instance $ORACLE_SID is already running!"
fi
# start listener
if [ "$lsnrpid" -eq "" ]; then
echo "Starting listener ..."
lsnrctl start
else
echo "Listener is already running!"
fi
# start Enterprise Manager
if [ "$empid" -eq "" ]; then
echo "Starting Enterprise Manager ..."
rm $ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/em/em/cabo/images/cache/*/*.gif
emctl start dbconsole
else
echo "Enterprise Manager is already running!"
fi
# start iSQLPLUS
if [ "$isqlpid" -eq "" ]; then
echo "Starting iSQLPLUS ..."
rm $ORACLE_HOME/oc4j/j2ee/oc4j_applications/applications/isqlplus/isqlplus/images/*.gif
isqlplusctl start
else
echo "iSQLPLUS is already running!"
fi
#
#
# check processes status
echo "/n--------------------------------"
echo "Checking Oracle processes status:"
orapid=`ps -ef | grep -v grep | grep $ORACLE_SID | awk '{print $2}' | head -1` lsnrpid=`ps -ef | grep -v grep | grep LISTENER | awk '{print $2}'`
if [ ! "$orapid" -eq "" ]; then
echo "Oracle instance $ORACLE_SID is running!"
fi
if [ ! "$lsnrpid" -eq "" ]; then
echo "Listener is running!"
fi
echo "--------------------------------/n"
# end
#!/usr/bin/ksh
# script to stop database
#
# set -x
if [ -f /export/home/oracle/product/10g/Sun10_oradb1/emctl.pid ]; then
echo 'Stop Enterprise Manager.../n'
emctl stop dbconsole
fi
# grep process id for oracle instance and listener
orapid=`ps -ef | grep -v grep | grep $ORACLE_SID | awk '{print $2}' | head -1` lsnrpid=`ps -ef | grep -v grep | grep LISTENER | awk '{print $2}'`
# stop oracle instance
if [ ! "$orapid" -eq "" ]; then
echo "Shutting down Oracle instance..."
sqlplus /nolog << !
connect /as sysdba
shutdown immediate
exit
!
fi
# stop listener
if [ ! "$lsnrpid" -eq "" ]; then
echo "Shutting down listener ..."
lsnrctl stop
fi
# check processes status
echo "--------------------------------"
echo "Checking Oracle processes status:"
orapid=`ps -ef | grep -v grep | grep $ORACLE_SID | awk '{print $2}' | head -1` lsnrpid=`ps -ef | grep -v grep | grep LISTENER | awk '{print $2}'`
if [ "$orapid" -eq "" ]; then
echo "Oracle instance $ORACLE_SID is stopped!"
fi
if [ "$lsnrpid" -eq "" ]; then
echo "Listener is stopped!"
fi
echo "--------------------------------/n"
# end