Skip to content

@rmoff /1-init-d_dbora.sh secret
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Oracle DB init.d script
#!/bin/sh
# chkconfig: 345 90 10
# description: Oracle auto start-stop script.
#
# Taken from http://www.oracle-base.com/articles/linux/automating-database-startup-and-shutdown-on-linux.php#oracle–11gr2-update
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database software.
#
# Install steps:
# 1. Create this file as /etc/init.d/dbora
# 2. chmod 750 /etc/init.d/dbora
# 3. chkconfig --add dbora
# 4. Create startup.sh and shutdown.sh in /home/oracle/scripts/
#
ORA_OWNER=oracle
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "/home/oracle/scripts/startup.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "/home/oracle/scripts/shutdown.sh >> /home/oracle/scripts/startup_shutdown.log 2>&1"
rm -f /var/lock/subsys/dbora
;;
esac
#!/bin/bash
#
# /home/oracle/scripts/shutdown.sh
#
# This script assumes that the following are set in your user profile and this is sourced before this script is run. If not, then put them in this script
# export TMPDIR=$TMP
# export TMP=/tmp
# export ORACLE_HOSTNAME=ol6-112.localdomain
# export ORACLE_UNQNAME=DB11G
# export ORACLE_BASE=/u01/app/oracle
# export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
# export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH
# export ORACLE_SID=DB11G
# ORAENV_ASK=NO
# . oraenv
# ORAENV_ASK=YES
# Start Listener
lsnrctl start
# Start Database
sqlplus / as sysdba << EOF
STARTUP;
EXIT;
EOF
#!/bin/bash
#
# /home/oracle/scripts/shutdown.sh
#
# This script assumes that the following are set in your user profile and this is sourced before this script is run. If not, then put them in this script
# export TMPDIR=$TMP
# export TMP=/tmp
# export ORACLE_HOSTNAME=ol6-112.localdomain
# export ORACLE_UNQNAME=DB11G
# export ORACLE_BASE=/u01/app/oracle
# export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
# export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH
# export ORACLE_SID=DB11G
# ORAENV_ASK=NO
# . oraenv
# ORAENV_ASK=YES
# Stop Database
sqlplus / as sysdba << EOF
SHUTDOWN IMMEDIATE;
EXIT;
EOF
# Stop Listener
lsnrctl stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.