Skip to content

Instantly share code, notes, and snippets.

@iacosta

iacosta/dbora Secret

Last active October 13, 2015 09:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save iacosta/c099e9e4ac237b510421 to your computer and use it in GitHub Desktop.
Oracle Database Start/Stop Automatic
#! /bin/bash
#
# oracle Start/Stop the Databases...By Ivan Acosta
#
# chkconfig: - 99 10
# description: oracle upstart
# processname: oracle
# config: /etc/oratab
# pidfile: /var/run/oracle.pid
# Source function library.
. /etc/init.d/functions
RETVAL=0
ORA_OWNER="oracle"
ORA_HOME="/u01/app/oracle/product/11.2.0"
AGENT_HOME="/u01/app/oracle/agent11g"
# See how we were called.
prog="oracle"
start() {
echo -n $"Starting $prog: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start listener_ssb"
su - $ORA_OWNER -c "$AGENT_HOME/bin/emctl start agent"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dbora
return $RETVAL
}
status() {
echo -n $"Status $prog: "
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl status"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl status listener_ssb"
su - $ORA_OWNER -c "$AGENT_HOME/bin/emctl status agent"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dbora
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop listener_ssb"
su - $ORA_OWNER -c "$AGENT_HOME/bin/emctl stop agent"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -r /var/lock/subsys/dbora
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
status)
status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|status|stop|restart}"
exit 1
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment