>Привет! :)
>
>Я пишу скрипт на ksh которий запускает в цикле 30 разных процесов
>в background. Мне нужно знать, когда все эти процесы закончатса. Как
>это можно сделать?
>
>например:
>
>....
>i=1
>while [[ $i -le 30 ]]
>do
> num=$(( $RANDOM % 60 ))
> sleep $num &
> i=$(( $i + 1 ))
>done
>
>ждать покаместь не закончатьса.
>.....
Привет!
Это из man ksh:
wait [job]
Wait for the specified job(s) to finish. The exit status of wait is that of the last specified job: if the last job is killed by a signal, the exit status is 128 + the number of the signal (see kill -l exit-status above); if the last specified job can't be found (because it never existed, or had already finished), the exit status of wait is 127. See Job Control below for the format of job. Wait will return if a signal for which a trap has been set is received, or if a HUP, INT or QUIT signal is received.
If no jobs are specified, wait waits for all currently running jobs (if any) to finish and exits with a zero status. If job monitoring is enabled, the completion status of jobs is printed (this is not the case when jobs are explicitly specified).
echo -n Test..
i=1
while [[ $i -le 30 ]]
do
num=$(( $RANDOM % 60 ))
sleep $num &
i=$(( $i + 1 ))
done
wait
echo .OK
В ksh не проверял, в bash работает.