Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

startup and shutdown script problem

Status
Not open for further replies.

mm8294

MIS
Joined
Oct 12, 2001
Messages
73
Location
US
My boss wants me to make a script to startup/shutdown our Oracle applications automatically when the Solaris server is rebooted. I made a script /etc/init.d/oracle.sh, created a link in /etc/rc3.d and tested it. Which is interesting is, it works fine if I run it manually, but doesn't when the server is rebooted. Below is the script, could any experienced guy take a look at it? I appreciate it.

#!/bin/sh


case "$1" in
'start')

######## Start the web servers ##################################################


ORACLE_SID=PBSPROD
export ORACLE_SID
APPL_TOP=/erp01/app/applmgr/PBSPROD
export APPL_TOP
ORACLE_HOME=/erp00/app/oracle/product/8.0.6
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/ows/3.0/bin:$ORACLE_HOME/bin:$ORACLE_HOME/utils:/var/opt/applmgr
export PATH
SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib
export SHLIB_PATH
TNS_ADMIN=/erp00/app/oracle/product/8.0.6/network/admin
export TNS_ADMIN
. $APPL_TOP/$ORACLE_SID.env
. /var/opt/oracle/userenv PBSPROD
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl start wrb"
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl start admin"
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl start www"
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl start PROD"

######### Start the form servers #############################################

ORACLE_SID=PBSPROD
export ORACLE_SID
. /var/opt/oracle/userenv PBSPROD
HOME=/export/home/applmgr
export HOME
su applmgr -c "f45ctl start port=9000 pool=0 log=$HOME/log/PBSPROD_fs.9000.log"
;;

'stop')
####### Stop the form servers ##############################################

ORACLE_SID=PBSPROD
export ORACLE_SID
. /var/opt/oracle/userenv PBSPROD
su applmgr -c "f45ctl stop port=9000"


######## Stop the web server ##############################################

ORACLE_SID=PBSPROD
export ORACLE_SID
APPL_TOP=/erp01/app/applmgr/PBSPROD
export APPL_TOP
ORACLE_HOME=/erp00/app/oracle/product/8.0.6
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/ows/3.0/bin:$ORACLE_HOME/bin:$ORACLE_HOME/utils:/var/opt/applmgr
export PATH
SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib
export SHLIB_PATH
TNS_ADMIN=/erp00/app/oracle/product/8.0.6/network/admin
export TNS_ADMIN
. $APPL_TOP/$ORACLE_SID.env

/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl stop USR

ORACLE_SID=PBSPROD
export ORACLE_SID
. /var/opt/oracle/userenv PBSPROD
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl stop PROD"
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl stop admin"
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl stop www"
su oracle -c "/erp00/app/oracle/product/8.0.6/ows/3.0/bin/owsctl stop wrb"
#### It takes three minutes for oraweb processes to cleanly shut down. View with ps -ef"
;;
*)
echo "Usage: /etc/init.d/oracle { start | stop }"
;;
esac
 
Hi:

I'm not an Oracle guy, but it's my experience when a program works from the command line and not during bootup, cron, or someother unattended process, that the problem is that PATH or some other environmental variable isn't being set.
 
olded, thank you very much for your post.

As you can see, the first 14 lines below 'start' should have already taken care of the environmental variables.

I found sth., but as far as I know, it should not cause any problem:

The previous UNIX sa did not create a link under /etc/rc3.d, instead he copied /etc/init.d/oracle to /etc/rc3.d
 
Hi:

I have to disagree with you. You are adding to $PATH with

PATH=$PATH:$ORACLE_HOME....

Are you sure that $PATH is really set before you start adding to it? I'd define my entire PATH and not rely on the boot process to set it.

 
What did you name your link in rc3.d or rc2.d?
 
To olded:

I have tested it and it seems $PATH is not a problem because ". /var/opt/oracle/userenv PBSPROD" will take care of it. What userenv do is:

...
if $PATH has been set, ...
elsif ...
fi
...

The link was created as /etc/rc3.d/S78oracle


 
Have you tried moving it to rc2.d?
 
Here is a suggestion that might help you out. I noticed when you were using the SU command you had just su oracle -c "some command". What you should try is replacing it with su - oracle -c "some command", that way it will load all of the Oracle users environment variables. When you use SU without a dash it does not do that.
 
Sorry, forgot to mention make that change on all of your users not just Oracle.
 
Coffeysm, thank you very much for your suggestion.

We use 'su oracle -c' instead of 'su -', because the .profile of oracle will prompt you to select from a list of databases and applications.
 
Then you might want to try adding the settings in your .profile to your startup script. My guess is there is probably something not being intialized. You said it works when you try it from the command line, which user are you trying it as oracle?
 
I ran it successfully from command line as root.
 
Maybe you can try adding a #!/bin/sh -x and disable CDE, and when it next boots up you can watch it to see where it craps out on you?
 
How did you run it from the command line?

I actually had a similar problem and to this day I cannot figure out why. An application would not start that was in rc2.d and as soon as I moved it to rc3.d it started working when the server rebooted. Why? I have no idea. The server was always running as run-level 3. It was my last try since I couldn't think of anything else.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top