Ubuntu Upstart Script for Oracle Database

Recent versions of Ubuntu use Upstart instead of System-V style initialization, so if you want Oracle to start at boot time then you’ll need an Upstart script for Oracle.

Create a file named /etc/init/oracle.conf:

gksu gedit /etc/init/oracle.conf

and add the following contents to the file:

description  "Oracle Database"
author       "https://cdivilly.wordpress.com"

# The location of the Oracle install
env ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
# The user to execute Oracle as
env ORACLE=oracle

start on (net-device-up
          and local-filesystems
	  and runlevel [2345])
stop on runlevel [016]

expect fork

pre-start script
    su - $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
end script

post-stop script
    su - $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
end script

You may need to modify the value of the ORACLE_HOME and ORACLE environment variables to match your local settings.

Advertisements