Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Oracle connection from ksh script 2

Status
Not open for further replies.

rousse

Programmer
Sep 24, 2003
12
US
Hello,

What is a simple way to check ONLY if Oracle is "alive", i.e. there is a connection from within a korn shell script?

Thank you.
 
man tnsping

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Vlad,

I tried - man tnsping - but got this:
No manual entry for tnsping.

What path is missing from the MANPATH env var?

Thanks.
PP
 
the man pages get installed [if specified] I believe under $ORACLE_HOME/man

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I've never seen man pages for Oracle. The doc that is installed for Oracle is in $ORACLE_HOME/doc and is in html and pdf format.

tnsping <instance_name> is used to see if the instance is running and reachable -- that is, is the listener able to connect you to the database. you get several lines of output to a tnsping. The last line says OK (xx msec) if the database is reachable.
 
Hi,

take a look on that side .....

I have an older version of dbup.sh like this:
VERBOSE=0
shift OPTIND-1

for INSTANCE in $DB
do
FAILED=0; INSTANCEDOWN=0
if [ ${VERBOSE} -eq &quot;1&quot; ] ; then
echo &quot;Checking instance ${INSTANCE}...\n&quot;
fi
for PROCESS in pmon smon
do
RC=$(ps -ef | egrep ${INSTANCE} | egrep -v 'grep' | egrep ${PROCESS})
if [ &quot;${RC}&quot; = &quot;&quot; ] ; then
INSTANCEDOWN=1
if [ ${VERBOSE} -eq &quot;1&quot; ] ; then
echo &quot;\tERROR: Instance ${INSTANCE} ${PROCESS} down!&quot;
fi
fi
done
if [ ${INSTANCEDOWN} = &quot;1&quot; ] ; then
echo &quot;`date` - Instance ${INSTANCE} is DOWN!!!\n&quot;
FAILED=1
else
echo &quot;`date` - Instance ${INSTANCE} is running.\n&quot;
fi
done

if [ ${FAILED} = 1 ] ; then
return -1
else
return 0
fi


this is a script for determing if an Instance is up and running. I got it working and its okay.

hth
Uwe
 
Hello,

I implemented successfully this:

${ORACLE_HOME}/bin/tnsping ${ORACLE_SID} > /dev/null
if [[ $? -eq 0 ]]; then
#Oracle is up...
#...do something...
else
#Oracle is down...
#...do something...
fi

Thanks.
<rousse>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top