I have the following script:
echo "$wk" | while read -r a b; do counter=$(($counter+1)) nohup sh -c 'impala-shell -d nielsen -f query.sql --var=dt=$a --var=incre=$b; echo $a,$?>>$week_status_file; if [ $? -ne 0 ]; then echo $a,$b>>$err_week_file fi' if [ $(($counter%5)) == 0 -a $counter -ge 5 ]; then echo "Check" wait fi done
The idea is to kick off the wrapped command
impala-shell... with two variables
b (coming from the variable
wk). This should be done in parallel with 5 processes. The next 5 jobs should wait until the previous 5 processes to finish. My current code prints out
Check, but it doesn't wait at all. However, if I change
sleep 10s, it does sleep.
How do I make
wait work here?