我正在扭曲shell脚本。我想要三个脚本在不同的终端运行。我在shell脚本中写了这样的内容,
gnome-terminal -x 1.sh
gnome-terminal -x 2.sh
gnome-terminal -x 3.sh
然后父终端正在等待执行gnome-terminal -x 1.sh
。当第一个脚本运行时,它不会继续下一个脚本。如果我将这3个脚本作为后台进程运行,它们会在3个不同的终端窗口运行但是,我无法杀死这3个进程。
我必须手动找到进程ID并杀死它们。我不想这样做。有没有更好的方法呢?
答案 0 :(得分:1)
您可以从启动它们的命令行中获取其进程ID:
gnome-terminal -x 1.sh & pid1=$!
gnome-terminal -x 2.sh & pid2=$!
gnome-terminal -x 2.sh & pid3=$!