/etc/rc.d/init.d/oracle
#!/bin/sh
# /etc/rc.d/init.d/oracle
ORACLE_BASE=/home/oracle/app/oracle;
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1;
case "$1" in
start)
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
echo -n "Starting Oracle Databases: "
su - oracle -c "dbstart $ORACLE_HOME"
#>> /var/log/oracle
echo "Done."
echo -n "Starting Oracle Listeners: "
su - oracle -c "lsnrctl start"
#>> /var/log/oracle
echo "Done."
echo -n "Starting Oracle emctl: "
su - oracle -c "emctl start dbconsole"
#>> /var/log/oracle
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
stop)
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Shutting Down Oracle Databases as part of system down." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
echo -n "Shutting Down Oracle Databases: "
su - oracle -c "dbshut $ORACLE_HOME"
#>> /var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
echo -n "Shutting Down Oracle Listeners: "
su - oracle -c "lsnrctl stop"
#>> /var/log/oracle
echo "Done."
echo -n "Shutting Down Oracle emctl: "
su - oracle -c "emctl stop dbconsole"
#>> /var/log/oracle
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
;;
restart)
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Restarting Oracle Databases as part of system up." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
echo -n "Shutting Down Oracle emctl: "
su - oracle -c "emctl stop dbconsole"
#>> /var/log/oracle
echo "Done."
echo -n "Shutting Down Oracle Listeners: "
su - oracle -c "lsnrctl stop"
#>> /var/log/oracle
echo "Done."
echo -n "Shutting Down Oracle Databases: "
su - oracle -c "dbshut $ORACLE_HOME"
#>> /var/log/oracle
echo "Done."
echo -n "Restarting Oracle Databases: "
su - oracle -c "dbstart $ORACLE_HOME"
#>> /var/log/oracle
echo "Done."
echo -n "Restarting Oracle Listeners: "
su - oracle -c "lsnrctl start"
#>> /var/log/oracle
echo "Done."
echo -n "Starting Oracle emctl: "
su - oracle -c "emctl start dbconsole"
#>> /var/log/oracle
echo "Done."
echo ""
echo "----------------------------------------------------" >> /var/log/oracle
date +"! %T %a %D : Finished." >> /var/log/oracle
echo "----------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
*)
echo "Usage: oracle {start|stop|restart}"
exit 1
esac