Shell脚本:subprocess不会在linux中终止

我写了一个shell脚本来同时启动三个后台进程。 在shell脚本中,我试图等待所有的孩子完成他们的工作,然后父母的工作终止。 但是,由于某种原因,我看到睡眠过程不会被唤醒。

echo "Starting $1 instances" >> $logfile for i in `seq 1 $1` do /usr/bin/php index.php name& done echo "Waiting for all $l instances to complete \n" >> $logfile wait echo "All $instances scripts completed" >> $logfile 

如果你正在使用bash ,你应该使用wait命令,而不是精心devise的轮询循环。 我不知道其他shell(sh,zsh等),但是我认为他们中的大多数/所有人都有wait ,或者等同于它。