File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes how to wait for non-child PID Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "how to wait for non-child PID" Watch "how to wait for non-child PID" New topic
Author

how to wait for non-child PID

Isha Mackker
Greenhorn

Joined: Oct 18, 2005
Posts: 29
Hi All,

I have written a shell script to update my web application, i.e. executing the shell script automatically stops the JBoss, replaces old ear file with new ear file and then start the JBoss.

I want the script to wait for the JBoss to stop and then start replacing the ear. I tried using wait $PID, extracting PID as:

PID=`ps -ef | grep 'jboss.sh' | tr -s " " | cut -d" " -f2`
PID=`echo $PID | cut -d" " -f1`

where jboss.sh is another script to stop the JBoss and then calling the wait as:

wait $PID

the issue with this is that it says:

test.sh: line 8: wait: pid 4215 is not a child of this shell.

Please help.
Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

For the most part, it's not a good idea to attempt to consort with threads in a process unrelated to your own. Among other things, they may be running on a seperate CPU, in a separate address space or be in some other way not part of the same universe as your process.

However, a bigger question is "why stop JBoss?" One of the features that JBoss excels at is on-the-fly app updating. In most cases, it's sufficient to simply deploy a new copy of your webapp and JBoss will shut down the old copy and start the new one. And it takes a lot less time than restarting the entire app container.


Customer surveys are for companies who didn't pay proper attention to begin with.
Isha Mackker
Greenhorn

Joined: Oct 18, 2005
Posts: 29
Yes, thats very true. I need not restart the JBoss.
Anyhow, to make the script wait, I can use this:
sleep 10s
this will make the script wait for 10 secs where 's' is a suffix to indicate seconds.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to wait for non-child PID