• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

how to wait for non-child PID

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 20847
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Isha Mackker
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!