Skip to content
Home » Oracle » How to Check if Oracle Database is Running

How to Check if Oracle Database is Running

To make sure that an Oracle database is alive, we can use a piece of shell script to check it.

[oracle@test ~]$ vi
. ~/.bash_profile

ps -ef | grep "ora_smon_$ORACLE_SID" | grep -v grep > /dev/null
if [ $? -eq 0 ]; then
        echo "Database $ORACLE_SID is alive!"
        echo "Database $ORACLE_SID is dead!"

The key is that we check the existence of the system monitor process (SMON) to determine the result in the above code.

To make it executable, we add execution permissin on user.

[oracle@test ~]$ chmod u+x

Let's test the script when the database is running.

[oracle@test ~]$ ./
Database ORCLCDB is alive!

What if the database is idle? Let's see what the result will be.

[oracle@test ~]$ ./
Database ORCLCDB is dead!

For a different ORACLE_SID, you may use oraenv to set the variable before checking.

The drawback of the script is that, it always returns a positive result as long as the instance is running, no matter what state it is. That is to say, a NOMOUNT database is also determined as being alive.

For further investigation, you may need a script to check the database status.

Leave a Reply

Your email address will not be published. Required fields are marked *