views:

24

answers:

1

I have the following requirement where there are 3 scripts say, a2,a3,a4

Now as per the requirement a2,a3 should be executed parallely and a4 sequentially.(ie., a4 should be executed only after the completion of a2&a3).

Now I tried this like,

((((echo 'start a2' `date`; nohup a2; echo 'end a2') >>log) &)
(((echo 'start a3'; nohup a3; echo 'end a3') >>log) &)  &&
(echo 'start a4';nohup a4; echo 'end a4') >>log)

assuming a2,a3 are send to the background by the '&' and a4 executes only after a2,a3 because of '&&' why doesn't this work?.(a4 executes before a3.I tried this by introducing delays in the scripts with sleep command) How should I go about writing this?. Thanks in advance.

+1  A: 

You need to wait for a2 and a3 to complete before you run a4. So look at the manual page for the wait command.

Jackson
Thanks!. wait is exactly what I was looking for!
jgua1