[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: launching jobs in a combined serial parallel way



Scott Gifford wrote:

> Kamaraju S Kusumanchi <raju.mailinglists@gmail.com> writes:
> 
> [...]
> 
>> progc should to be launched only after both proga, progb are finished.
>> progc takes another couple of hours to finish.
>>
>> What is good way to automate this problem (that is no manual
>> interaction)?
> 
> In a shell script, run proga and progb in the background, then wait
> for them both with the "wait" builtin.  Something like this:
> 
>     #!/bin/sh -e
>     # -e flag will abort on any error
>     proga &    # Start proga in background
>     progb &    # Start progb in background
>     wait       # Wait for whichever finishes first
>     wait       # Wait for the other one
>     progc      # Now run progc in the foreground
> 
> ----Scott.

This is great. A little perusal of 'man wait' gave me a better idea.

nohup proga &
pa=$!
nohup progb &
pb=$!
wait $pa $pb
nohup progc &

Thanks a lot. Just what I am looking for.

raju
-- 
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/


Reply to: