|
 |
|
ss
Oracle Tips by Burleson |
Terminate the script if the
database is down
This section of the script skips any database that is not running at
the time the script executes. By doing this, we avoid false errors
messages in a large environment, where a database might be down for
a cold backup or DBA maintenance.
We perform a double check, first checking to see if the PMON
background process is running, and another that attempts a
connection to the database. If either fails, the script terminates.
#*************************************************************
# Let's exit immediately if the database is not running . . .
#*************************************************************
check_stat=`ps -ef|grep ${ORACLE_SID}|grep pmon|wc -l`;
oracle_num=`expr $check_stat`
if [ $oracle_num -lt 1 ]
then
exit 0
fi
#*************************************************************
# Test to see if Oracle is accepting connections
#*************************************************************
$ORACLE_HOME/bin/sqlplus -s /<<! > /tmp/check_$ORACLE_SID.ora
select * from v\$database;
exit
!
#*************************************************************
# If not, exit immediately . . .
#*************************************************************
check_stat=`cat /tmp/check_$ORACLE_SID.ora|grep -i error|wc -l`;
oracle_num=`expr $check_stat`
if [ $oracle_num -gt 0 ]
then
exit 0
fi
Download your Oracle scripts now:
www.oracle-script.com
The
definitive Oracle Script collection for every Oracle professional DBA
|
|