SHUTDOWN THE DATABASE WITH IMMEDIATE MODE / Shell script


echo "----------------------------------------------------------------------------"
 echo Report by Anar Godjaev Oracle 9i/10g/11g OCA,OCP,SQL Expert, PL/SQL Prof,RAC
 echo "----------------------------------------------------------------------------"
#!/bin/ksh
 # This shell script performs the following steps
 # shutdown the database with immediate mode
 # log file
 ORACLE_HOME=/data1/oracle/product/8.1.7 ; export ORACLE_HOME
 ORACLE_SID=ORCL export ORACLE_SID
 LOGFILE=/data1/oracle/admin/ORCL/log/anar.log
 clear
 echo "Obase-1 the database is closed."
 echo " Are you sure you? (yes/no) :\c"
 read RESPONSE
 if [ $RESPONSE != 'yes' ] ;
 then
 echo
 echo " The database is closed."
 echo
 exit -1
 fi
 echo ""
 echo " The immediate closure of the database..."
 echo ""
 $ORACLE_HOME/bin/sqlplus -SILENT /nolog <<EOF
 WHENEVER SQLERROR EXIT -2
 WHENEVER OSERROR EXIT -2
 connect internal
 shutdown immediate
 exit 0
 EOF
 exit_code=$?
 # if shutting down the database fails, then write error message and exit
 if [ $exit_code -eq 0 ];
 then
 echo ""
 echo "`date`\t$LOGNAME\t Database CLOSED." | tee -a $LOGFILE
 echo ""
 else
 echo ""
 echo "`date`\t$LOGNAME\t Database is not closed." | tee -a $LOGFILE
 echo ""
 exit -2
 fi
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: