Re: Map database to running instance from oratab?

From: Ethan Post <>
Date: Tue, 24 Jul 2012 12:14:10 -0500
Message-ID: <>

Thanks for all who contributed answers, seems there are no easy answers. Ideally some of these things would be exposed externally without having to look into the database. There are things I might like to know before I even log in with a script. Is it running, is it a standby, is it rac non-rac, what is the instance name...
Anyway here is what I came up with, this is my script. Makes use of a couple other
custom scripts.

. DATABASE "${1}" | grep "^${1}$" | while read DATABASE; do

   INSTANCE=$(ps -ef | grep "[ora|asm]_smon_${DATABASE}$" | grep -v "grep" | cut -d"_" -f3)

   if [[ -z "${INSTANCE}" ]]; then

      while (( ${i} < 5 )); do
         INSTANCE=$(ps -ef | grep "[ora|asm]_smon_${DATABASE}${i}$" | grep
-v "grep" | cut -d"_" -f3)
         [[ -n "${INSTANCE}" ]] && break


if [[ -z ${INSTANCE} ]]; then "$0" "Failed to map instance to database ${1}. Verify database is running and in oratab file." else

   echo ${INSTANCE}

Received on Tue Jul 24 2012 - 12:14:10 CDT

Original text of this message