Linux 无法在并行脚本中使用位置参数

Linux 无法在并行脚本中使用位置参数,linux,bash,shell,sh,Linux,Bash,Shell,Sh,我有一堆脚本将3个位置参数传递给另一个脚本。当我连续运行它时,它工作正常 裂土器.sh #!/bin/bash -e set -x # Sock Puppets!!! ./automate_tests.sh quorum t2.xlarge us-east-1 ./automate_tests.sh quorum t2.2xlarge us-east-1 ./automate_tests.sh quorum t3.2xlarge us-east-1 ./automate_tests

我有一堆脚本将3个位置参数传递给另一个脚本。当我连续运行它时,它工作正常

裂土器.sh

#!/bin/bash -e

set -x

# Sock Puppets!!!


./automate_tests.sh quorum t2.xlarge us-east-1 
./automate_tests.sh quorum t2.2xlarge us-east-1 
./automate_tests.sh quorum t3.2xlarge us-east-1 
./automate_tests.sh quorum t3a.xlarge us-west-1 
./automate_tests.sh quorum t3a.2xlarge us-west-1 
./automate_tests.sh quorum a1.4xlarge  us-west-1 
./automate_tests.sh quorum a1.metal ca-central-1 
./automate_tests.sh quorum m4.xlarge ca-central-1 
./automate_tests.sh quorum m4.2xlarge  ca-central-1 
./automate_tests.sh quorum m4.4xlarge eu-central-1 
./automate_tests.sh quorum m4.10xlarge eu-north-1 
./automate_tests.sh quorum m4.16xlarge eu-north-1 
./automate_tests.sh quorum m5.2xlarge eu-north-1 
./automate_tests.sh quorum m5.4xlarge eu-north-1 
./automate_tests.sh quorum m5.8xlarge eu-west-3 
./automate_tests.sh quorum m5.12xlarge eu-west-3 
./automate_tests.sh quorum m5.16xlarge  eu-west-3 
./automate_tests.sh quorum m5.24xlarge eu-west-3 
./automate_tests.sh quorum m5.metal eu-west-1 
#!/bin/bash -e

set -x

CLIENT=$1
VM_FAMILY=$2 
REGION=$3
自动化测试。sh

#!/bin/bash -e

set -x

# Sock Puppets!!!


./automate_tests.sh quorum t2.xlarge us-east-1 
./automate_tests.sh quorum t2.2xlarge us-east-1 
./automate_tests.sh quorum t3.2xlarge us-east-1 
./automate_tests.sh quorum t3a.xlarge us-west-1 
./automate_tests.sh quorum t3a.2xlarge us-west-1 
./automate_tests.sh quorum a1.4xlarge  us-west-1 
./automate_tests.sh quorum a1.metal ca-central-1 
./automate_tests.sh quorum m4.xlarge ca-central-1 
./automate_tests.sh quorum m4.2xlarge  ca-central-1 
./automate_tests.sh quorum m4.4xlarge eu-central-1 
./automate_tests.sh quorum m4.10xlarge eu-north-1 
./automate_tests.sh quorum m4.16xlarge eu-north-1 
./automate_tests.sh quorum m5.2xlarge eu-north-1 
./automate_tests.sh quorum m5.4xlarge eu-north-1 
./automate_tests.sh quorum m5.8xlarge eu-west-3 
./automate_tests.sh quorum m5.12xlarge eu-west-3 
./automate_tests.sh quorum m5.16xlarge  eu-west-3 
./automate_tests.sh quorum m5.24xlarge eu-west-3 
./automate_tests.sh quorum m5.metal eu-west-1 
#!/bin/bash -e

set -x

CLIENT=$1
VM_FAMILY=$2 
REGION=$3
不幸的是,当我尝试使用
nohup sh ripper.sh>out&
以并行作业的形式运行
ripper.sh
并按如下所示进行编辑时,它不会将位置参数传递给
automatic\u tests.sh

#!/bin/bash -e

set -x

# Sock Puppets!!!


./automate_tests.sh quorum t2.xlarge us-east-1 &
./automate_tests.sh quorum t2.2xlarge us-east-1 &
./automate_tests.sh quorum t3.2xlarge us-east-1 &
./automate_tests.sh quorum t3a.xlarge us-west-1 &
./automate_tests.sh quorum t3a.2xlarge us-west-1 &
./automate_tests.sh quorum a1.4xlarge  us-west-1 &
./automate_tests.sh quorum a1.metal ca-central-1 &
./automate_tests.sh quorum m4.xlarge ca-central-1 &
./automate_tests.sh quorum m4.2xlarge  ca-central-1 &
./automate_tests.sh quorum m4.4xlarge eu-central-1 &
./automate_tests.sh quorum m4.10xlarge eu-north-1 &
./automate_tests.sh quorum m4.16xlarge eu-north-1 &
./automate_tests.sh quorum m5.2xlarge eu-north-1 &
./automate_tests.sh quorum m5.4xlarge eu-north-1 &
./automate_tests.sh quorum m5.8xlarge eu-west-3 &
./automate_tests.sh quorum m5.12xlarge eu-west-3 &
./automate_tests.sh quorum m5.16xlarge  eu-west-3 &
./automate_tests.sh quorum m5.24xlarge eu-west-3 &
./automate_tests.sh quorum m5.metal eu-west-1 &
wait 
输出

 + CLIENT=
 + VM_FAMILY=
 + REGION=
变量为空。如果有人能给我指点一下如何让它发挥作用,我将不胜感激

更新
我发现,当我运行脚本而不使用
nohup
时,它可以工作。我需要能够运行这些过程超过6个小时,因此需要一种方法来让它工作。你能确认一下,当你将你的文章中的脚本复制粘贴到一个新目录中时,你可以重现这个问题吗(不需要重复使用你现有的文件)?添加
&
不会使
$1
$2
,以及
$3
突然变为空。您的问题中还缺少其他内容。@SamuelDare
ripper.sh>out.txt
仅重定向标准输出;若要重定向标准错误,请使用
ripper.sh>out.txt 2>&1
。此外,我同意John Kugelman的观点——还有一些事情不在您的问题中。我建议复制脚本,然后尽可能简化它们。例如,删除automatic_tests.sh的多次运行,并查看问题是否仍然存在。从两个脚本中删除除问题部分以外的所有内容,然后再次测试。然后从ripper.sh上拆下
,然后再次测试。在不解决问题的情况下,尽可能多地消除并发症。然后,发布问题脚本的精简版本。
nohup
可能是其中的一部分,但不是全部。顺便说一句,并行版本对我来说就像预期的一样,有和没有
nohup
。所以还有别的事情发生了。