Home > Run Script as a Oracle user > Run Script in Linux as a Oracle user

Run Script in Linux as a Oracle user

To run script as a oracle user we have to use su command which means change user ID or become super-user


su [ - ] [ username [ arg ] ]

Pass the environment along unchanged, as if the user actually logged in as the specified user.

username The name of another username that you wish to log in as.

arg Additional arguments that need to be passed through the su command.

To run a script create_user.sql in oracle user use the following script

su - oracle -c $ORACLE_HOME/bin/sqlplus -s <<!
/ as sysdba

To run some Java console base application from rc.local as a Oracle User

[oracle@www ~]$ vi /etc/rc.local
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
su - oracle /home/oracle/runApp.sh

Write a script to run a jar file as a demon process (use &), you can also run a class file in the same way.

[oracle@www ~]$ vi runApp.sh
export JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
java -jar /home/oracle/AktelCMP.jar &

N.B: You can also run pearl or any other application in the same way.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: