File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "how to wait for non-child PID" Watch "how to wait for non-child PID" New topic

how to wait for non-child PID

Isha Mackker

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 '' | tr -s " " | cut -d" " -f2`
PID=`echo $PID | cut -d" " -f1`

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

wait $PID

the issue with this is that it says: line 8: wait: pid 4215 is not a child of this shell.

Please help.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

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.

An IDE is no substitute for an Intelligent Developer.
Isha Mackker

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.
I agree. Here's the link:
subject: how to wait for non-child PID
It's not a secret anymore!