I am running a command that's processing some data in one shell window (let's say it has pid 200). Unfortunately I forgot to add the & to run it in the background.

I need to run some analysis script after pid 200 is finished. I thought I could just open up another shell window and do

wait 200; ./myanalysis.sh

But it complains to me

"-bash: wait: pid 200 is not a child of this shell"

With that in mind, is there a way I can execute my analysis script automatically after this process terminates?

link|improve this question

75% accept rate
feedback

1 Answer

Can you use ^z and then do the following?

wait 200; ./myanalysis.sh&
fg %1

This will wait till pid 200 is finished, then run your analysis, and then will put itself in foreground.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.