Database Administration (MOSC)

MOSC Banner

Check if database is open via ksh script

edited Jun 26, 2013 6:40AM in Database Administration (MOSC) 10 commentsAnswered ✓
I have the following code to check if database is up and running and it works in most cases but sometimes I get an error
"ORA-01219: database not open: queries allowed on fixed tables/views only".

ps -ef|grep -v grep| grep $ORACLE_SID | grep ora_pmon > /dev/null
        if (( $? == 0 )) # is the pmon process running zero is yes
        then
                #check if sqlplus is installed
                if [ -f $ORACLE_HOME/bin/sqlplus ]
                then
                        sqlplus -s "/ as sysdba" <<! >> $FILE1
                        set lines 132
                        set wrap off
   select * from dba_data_files;
                        exit;

!

                fi
        fi


If I just run select name from v$database;, it returns the result without an issue but does not work on dba_data_files and other similar tables and views.

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center