1

我有以下 for 循环,该循环使用客户 ref 和 Du Id 处理 100

echo SCRIPT: $0

# TEST.sh arguments
# $1 = Order Ref
# $2 = DU ID
# $3 = Service Level.
# $4 = PostCode, Example EAST 4600 WEST 6900.
# $5 = Weight, to test PD_MAXI-C.

echo "Enter Customer Order Ref (e.g. 20001000)"
read P_CUST_ORDER_REF
echo "Enter DU Id (e.g. 20001000)"
read P_DU_ID


echo "-------------------LOGISTICAPOST------------------"

set -vx
for i in {1..100}
do
  echo "This should return PD_PRIVATPAKKER_E"
  ./1161-I-007-Consignor_Performance_Test.sh ${P_CUST_ORDER_REF} ${P_DU_ID} LOGISTICAPOST 4600 5000 &

  (( P_CUST_ORDER_REF++ ))
  (( P_DU_ID++ ))
done

我试图让它并行运行 100 个实例并处理它们。但是,当我运行此脚本时,我会收到 1 个回复。应该发生的是它处理了 100 个订单并将 100 条记录放入表中。我究竟做错了什么。

4

1 回答 1

3

I thought that GNU Parallel may be useful here. It allows to run command in parallel, like you wish. See man page with lot of examples.

于 2012-06-19T10:49:19.650 回答