Veritabaninin shutdow ve start edilmesi uchun shell script


# db_start.sh
#!/bin/ksh
# Veritabanin Acilmasi
# log file
ORACLE_HOME=/data1/oracle/product/11.2.0.3 ; export ORACLE_HOME
ORACLE_SID=ORCL export ORACLE_SID
LOGFILE=/data1/oracle/admin/ORCL/log/operation.log
echo
echo ""
echo "veritabanin Acilmasi..."
echo ""
$ORACLE_HOME/bin/sqlplus -SILENT /nolog <<EOFrestrict
 WHENEVER SQLERROR EXIT -2
 WHENEVER OSERROR EXIT -2
 connect internal
 startup
 exit 0
EOFrestrict
exit_code=$?
if [ $exit_code -eq 0 ];
 then
 echo ""
 echo "`date`\t$LOGNAME\tVeritabani Acildi." | tee -a $LOGFILE
 echo ""
 else
 echo ""
 echo "`date`\t$LOGNAME\tVeritabani Acilmadi." | tee -a $LOGFILE
 echo ""
 exit -3
 fi
#################################################################################
# db_stop.sh
#!/bin/ksh
# Veritabanin Shutdow Edilmesi
# log file
ORACLE_HOME=/data1/oracle/product/11.2.0.3 ; export ORACLE_HOME
ORACLE_SID=ORCL export ORACLE_SID
LOGFILE=/data1/oracle/admin/ORCL/log/operation.log
clear
echo "ORCL Veritabani shutdown edilecekdir."
echo "Tesdiq Edirsinizmi ? (yes/no) :\c"
read RESPONSE
if [ $RESPONSE != 'yes' ] ;
then
 echo
 echo "Shell scriptde xeta olusdu."
 echo "Veritabani shutdown edilmedi."
 echo
 exit -1
fi
echo ""
echo "veritabaninin immediate olarak sondurulmesi..."
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 [ $exit_code -eq 0 ];
 then
 echo ""
 echo "`date`\t$LOGNAME\tVeritabani shutdown edildi." | tee -a $LOGFILE
 echo ""
 else
 echo ""
 echo "`date`\t$LOGNAME\tVeritabani shutdown edilmedi." | tee -a $LOGFILE
 echo ""
 exit -2
 fi

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: