Automatically start oracle database on linux after server reboot

Here i show you how to configure system for automatically start oracle database after server reboot.
oracle database 11g — Oracle Linux 6.3
First of all, you need to make sure that any database instances you want to auto start are set to “Y” in the /etc/oratab file

# This file is used by ORACLE utilities.  It is created by
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
# Entries are of the form:
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
# Multiple entries with the same $ORACLE_SID are not allowed.

Oracle 11g includes 2 scripts which can be used to start or shut down Oracle databases on Linux. Both scripts are in $ORACLE_HOME/bin and called dbstart and dbshut. We can add some more actions for example start enterprise manager if we create our scripts. Let’s make two scripts and
vi /u0/app/oracle/

# script to start the Oracle database, listener and dbconsole
. ~/.bash_profile
# start the listener and the database
# start the Enterprise Manager db console
$ORACLE_HOME/bin/emctl start dbconsole
exit 0

vi /u0/app/oracle/

# script to stop the Oracle database, listener and dbconsole
. ~/.bash_profile
# stop the Enterprise Manager db console
$ORACLE_HOME/bin/emctl stop dbconsole
# stop the listener and the database
exit 0

inside script we are calling the .bash_profile file of the user “oracle” for export environment variables, we need it for $ORACLE_HOME.
give execute right:
chmod u+x
With user root, create a file called “oracle” under /etc/init.d
vi /etc/init.d/oracle

case "$1" in
        # Start the Oracle databases:
        su - $ORA_OWNER -c "/u0/app/oracle/"
        touch /var/lock/subsys/oracle
        # Stop the Oracle databases:
        su - $ORA_OWNER -c "/u0/app/oracle/"
        rm -f /var/lock/subsys/oracle
        echo $"Usage: $0 {start|stop}"
exit $RETVAL

change permission for /etc/init.d/oracle file:
chmod 750 /etc/init.d/oracle
to create service of this script:

chkconfig --add oracle

and now we can start and stop database with:

service oracle stop
service oracle stop

Now it’s time to test our automatically startup procedure, for this reboot your server and check if your database starts automatically after reboot.


3 thoughts on “Automatically start oracle database on linux after server reboot

  1. kostyanius

    Hi. Good script for starting database. But it would be nice if to have script for starting applications too. )

  2. Roger Mackbach

    I hope this works. I had a few problems following what you typed here. I am a newbie to Linux. I am running Oracle Linux, and every time I reboot the server, I can not restart the Enterprise manager.

    When doing the steps, it would not let me save the files a few times in the terminal window, so I used Gedit to create them. Then I had to log in as root to create the last one. However, I got an error when inputing the last command. chkconfig –add oracle, “service oracle does not support chkconfig”

    Please advise.
    Thanks for all the help.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s