#!/bin/ksh # ----------------------------------------------------------------------- # Filename: wait4ora.ksh # Purpose: Sleep until a database becomes available # Author: Frank Naude, Oracle FAQ # ----------------------------------------------------------------------- LOG=$0.log SLEEP_TIME=60 if [ ! -t 0 ]; then # Write output to log if we run from cron exec 1>>${LOG} 2>&1 fi if [ "${1}" = "" ]; then echo "USAGE: Please supply a database name..." exit fi unset TWO_TASK export ORACLE_SID=${1} export ORACLE_HOME=`grep -i "^${1}:" /etc/oratab|cut -d: -f2 -s` export PATH=$ORACLE_HOME/bin:$PATH echo "" echo "Waiting for database $1 to become available..." echo "Database: $ORACLE_SID Home: $ORACLE_HOME" while : do sqlplus -s >/dev/null 2>&1 "monitor/monitor" <<EOF whenever sqlerror exit 1 select * from dual; -- If we can not connect or select, we will not return 0!!! exit 0 EOF if [ $? -eq 0 ]; then echo "`date`: Database $ORACLE_SID is up and running." exit else echo "`date`: Still waiting for $ORACLE_SID to become available..." sleep ${SLEEP_TIME} fi done
Mário Macedo de Souza Jr.
Database Consulting
Desk +55 (11) 2183-2369
Mobile +55 (11) 9315-8921
Fax + 55 (11) 2183-2113
Rua Maria Coelho Aguiar, 215 - Bloco E - 5. Andar
São Paulo / SP - Brazil - CEP: 05804-900
Database Consulting
Desk +55 (11) 2183-2369
Mobile +55 (11) 9315-8921
Fax + 55 (11) 2183-2113
Rua Maria Coelho Aguiar, 215 - Bloco E - 5. Andar
São Paulo / SP - Brazil - CEP: 05804-900