Automating Startup / Shutdown in Linux

As root user create new file “oracle”
(init script for startup and shutdown the database) in /etc/init.d/ directory with following content:


#!/bin/bash
#
# oracle Init file for starting and stopping
# Oracle Database. Script valid for 10g and 11g.
#
# chkconfig: 35 80 30
# description: Oracle Database startup script# Source function library.

. /etc/rc.d/init.d/functions
ORACLE_OWNER=”oracle”
ORACLE_HOME=”/u01/app/oracle/11.2.0/db_1″
case “$1″ in

start)
echo -n $”Starting Oracle DB:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/dbstart $ORACLE_HOME”
echo “OK”
;;

stop)
echo -n $”Stopping Oracle DB:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/dbshut $ORACLE_HOME”
echo “OK”
;;

*)
echo $”Usage: $0 {start|stop}”
esac

Execute (as root) following commands (First script change the permissions, second script is configuring execution for specific runlevels):
chmod 750 /etc/init.d/oracle
chkconfig –add oracle –level 0356

Leave a Reply

Your email address will not be published. Required fields are marked *