The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 08-14-2007
robotronic's Avatar
robotronic robotronic is offline
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Testing if "the current DB still connected or not" doesn't really mean anything. I think you need to know "if the database is open", and so if user's connections are allowed. For that, you can run this simple script on the Oracle server machine:

Code:
USER="myuser"
PASS="mypassword"
$ORACLE_HOME/bin/sqlplus -s ${USER}/${PASS} <<EOF >/dev/null 2>&1
whenever oserror exit 98;
whenever sqlerror exit 99;
exit 140;
EOF

if [ "$?" -ne 140 ]
then
   echo "Oracle is down!"
else
   echo "Oracle is up."
fi
Of course, you can try to run this also on a client machine, although the result will be inaccurate: you may not be able to connect to the database for other problems (i.e. listener down) but the database on the server is up & running.

Hope this helps

Last edited by robotronic; 08-22-2007 at 09:57 AM.
Reply With Quote