2011-11-17 55 views
0

我是扭转的shell脚本。我想要三个脚本运行在不同的终端。我在shell脚本写了这个样子,如何在不同的终端上运行gnome终端子进程

gnome-terminal -x 1.sh

gnome-terminal -x 2.sh

gnome-terminal -x 3.sh

然后父终端正在等待完成为gnome-terminal -x 1.sh执行。当第一个脚本运行时,它不会继续下一个脚本。如果我将这3个脚本作为后台进程运行,它们将在3个不同的终端窗口中运行,但是我不能杀死这3个进程。

我必须手动找到进程ID并杀死它们。我不想这样做。有没有更好的方法来做到这一点?

回答

1

你可以从他们推出的命令行的进程ID:

gnome-terminal -x 1.sh & pid1=$! 
gnome-terminal -x 2.sh & pid2=$! 
gnome-terminal -x 2.sh & pid3=$!