why script fails sometime?

Hi,

I am trying to run a shell script on solaris,some time it works fine and some times it fails unexpectedly. There is a script called "autostart.sh" which automatically starts the Application server but some times the script fails to strat the application server. can anyone tell me what is the reason , why it dn't work properly .
The Script is ;
____________________________________________
#!/bin/bash
/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/ ./startManager.sh
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/ .startNode.sh
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/ ./startServer.sh server1
/opt/IBM/HTTPServer/bin/ ./apachectl start
_______________________________________________

Thanks in advance.

I'm surprised it ever works... why are there spaces between the directory name and the script name? Try making it like this:

#!/bin/bash
/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/startManager.sh
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startNode.sh
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startServer.sh server1
/opt/IBM/HTTPServer/bin/apachectl start

Thanks Annihilannic

#!/bin/bash
/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/./startManager.sh
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/.startNode.sh
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/./startServer.sh server1
/opt/IBM/HTTPServer/bin/./apachectl start

.......... Spaces are not in script , i know it will not work if there would be any space, i m sure that there is no error in this scrips and at this time script is running but some time it works and some time no.I have automate and it works on system stratup , I don't know why this problem occurs.

When does it work and when does it not work? Does it work when you run it manually, but not when you system boots up? Or is it completely random... i.e. sometimes when you run it manually it works, sometimes it doesn't?

Yes it runs manually and at startup as well . but some times it does't start all the services mentioned in the script . On system boot some times it works but some time does't .

what could be the problem and why is works some time or why i does't work some times.
if u have any idea then write here. waiing for your reply .
Thank you ..

Do these scripts output any "interesting" information? Do the processes themselves keep logfiles??

The scripts mentioned here are the default start scripts for IBMs Websphere product. They themselves run a whole lot of commands and any of these commands can fail for some or the other reason.

In other words: nothing of the information you gave us so far is sufficient to find out the reason. our script calls four other scripts and this process probably never fails and never will fail. That does not mean, though, that all the scripts started this way will finish sucessfully - each of them could fail for some or other reason. I have worked with a server running Websphere once and i know that it can be tricky sometimes to find ot why it failed to start.

I fear it will boil down to thorough troubleshooting on your side to find out the reason. The following are just some (very general) suggestions which may or ma not help you find the problem.

  • You run your script under bash instead of ksh. bash is not the systems default shell and hence using it a potential risk. While i suppose it won't make any difference it is on the safer side to use "/bin/ksh" instead of bash.

  • Try inserting "set -x" at the start of the four mentioned scripts and capture the output to some file to see what is going on:

#!/bin/ksh
/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/startManager.sh  >/tmp/start.1.log 2>&1
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startNode.sh  >/tmp/start.2.log 2>&1
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startServer.sh server1 >/tmp/start.3.log 2>&1
/opt/IBM/HTTPServer/bin/apachectl start >/tmp/start.4.log 2>&1

If something fails you can analyze the files /tmp/start[1-4].log then. This will not fix any problem itself, just help you analyze the situation when it happens.

I hope this helps.

bakunin

sory i could't undestand "interesting" , problem not a joke?

This script auto starts the application server and apache on system stratup It works fine but some times it fails and the script does't start the application server or appache . means that script fails. have u nay idea , if then write .
thanks

i have automated it using the procedure below

for example my scrip name is "autoscript.sh"

#!/bin/ksh
/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/bin/startManager.sh >/tmp/start.1.log 2>&1
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startNode.sh >/tmp/start.2.log 2>&1
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/startServer.sh server1 >/tmp/start.3.log 2>&1
/opt/IBM/HTTPServer/bin/apachectl start >/tmp/start.4.log 2>&1

After writing this script . i have copied it into /etc/init.d/ directory and then i have created a link in /etc/rc3.d/ directory using command " ln -s /etc/init.d/autoscript.sh S99script

So this works fine but i don't know some times it stops working . May be there is some problem with application server or may be due to automation .
if u have any idea then write here.
Thanks

Have you looked at the log files? What do they read like when the process fails?

Have yo inserted "set -x" or "set -xv" into the scripts mentioned in your script?

bakunin