Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to check whether the Oracle database is up?
Billy Verreynne wrote:
> Sri wrote:
>
>
>>Using a script, I want to check whether my database instance has been >>started and mounted or not. >>What is the best way to do this?
How about something like for unix, bear in mind 'garbage in = garbage out' ;
#!/bin/ksh # # Oracle status script # # Joe Bloggs # A company, # 30/08/2002 # # OVERVIEW # ======== # Checks for the existance of a 'pmon' process for the given ORACLE_SID # this is oracle's recommended way of determining whether an instance # is up. # # Rule being, if there is no pmon there *cannot* be a running instance ! # # Return Codes : 0 selected instance is UP # 1 selected instance is DOWN#
# # Functions #
usage()
{
echo Usage : `basename $0` ORACLE_SID exit 1
# # Main #
# we require a valid ORACLE_SID
if [ $# -ne 1 ]; then
usage
fi
ORACLE_SID=$1 ps -ef | grep [o]ra_pmon_$ORACLE_SID$ > /dev/null 2>&1 ret=$?
if [ $ret -eq 0 ]; then
# Oracle instance $ORACLE_SID appears to be up exit 0 else # Oracle instance $ORACLE_SID appears to be down exit 1