How to create /etc/init.d/dbora file in Azure VM for Oracle database

In this tutorial we will learn how to create and edit /etc/init.d/dbora file to automate the startup/shutdown of an Oracle database.

2 min read

In this tutorial we will learn how to create and edit /etc/init.d/dbora file to automate the startup/shutdown of an Oracle database.



  1. Sign on as root
sudo su -

2.  Create an empty /etc/init.d/dbora file as follows:

touch /etc/init.d/dbora

3.  See if file has been created successfully by using following command:

cat /etc/init.d/dbora

It will show nothing but if any error prompts then repeat from step 1

4.  Using vim editor we will edit the file /etc/init.d/dbora and save the changes:

vi /etc/init.d/dbora

You will see output that looks similar to the following:



5.  Type i to enter insert mode.

6.  Copy and paste the following code as follows:

#!/bin/sh
# chkconfig: 345 99 10
# Description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to $ORACLE_HOME.
ORA_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
ORA_OWNER=oracle

case "$1" in
'start')
    # Start the Oracle databases:
    # The following command assumes that the Oracle sign-in
    # will not prompt the user for any values.
    # Remove "&" if you don't want startup as a background process.
    su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
    touch /var/lock/subsys/dbora
    ;;

'stop')
    # Stop the Oracle databases:
    # The following command assumes that the Oracle sign-in
    # will not prompt the user for any values.
    su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" &
    rm -f /var/lock/subsys/dbora
    ;;
esac

Press ESC and then type :wq! then press Enter to save the changes and exit vim.

Whoa! you have created and saved  the changes in /etc/init.d/dbora file using bash shell editor.



Confirming the Changes

  1. Open the file again using following command
cat /etc/init.d/dbora

You will see output that looks similar to the following:

verify changes in dbora file
Verify the changes


Featured Oracle

Connect Oracle Database to Datagrip IDE

In this tutorial, we will connect the Oracle database to the DataGrip IDE.

2 min read
Featured Oracle

How to install Oracle database in Microsoft Azure VM

In this tutorial, we will learn how to set up an Oracle database on a remote server and access it by using our browser.

7 min read