Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 如何并行运行多个shell脚本?_Bash_Shell_Unix - Fatal编程技术网

Bash 如何并行运行多个shell脚本?

Bash 如何并行运行多个shell脚本?,bash,shell,unix,Bash,Shell,Unix,我正在并行运行shell脚本,如下所示。两个脚本的返回代码都是零,但其中一个脚本实际返回2。你知道会有什么问题吗。根据返回代码,我决定它是否成功/失败 ./shellscript1.sh & pid1=$! ReturnCode=$? ./shellscript2.sh & pid2=$! checkFlagReturnCode=$? wait $pid1 wait $pid2 无法捕获尚未完成的后台进程的返回代码。您可以从wait获取返回代码,而不是从$?获取返回代码。

我正在并行运行shell脚本,如下所示。两个脚本的返回代码都是零,但其中一个脚本实际返回2。你知道会有什么问题吗。根据返回代码,我决定它是否成功/失败

./shellscript1.sh & pid1=$!
ReturnCode=$?

./shellscript2.sh & pid2=$!
checkFlagReturnCode=$?


wait $pid1
wait $pid2

无法捕获尚未完成的后台进程的返回代码。您可以从
wait
获取返回代码,而不是从
$?

获取返回代码。他们有很多例子。

请详细说明如何从Wait获取返回码。此解决方案非常有用。非常感谢。