小编Ric*_*ins的帖子

Bash 运行多个程序并处理关闭

我有一个运行多个程序的 bash 脚本

#!/bin/sh
python program1.py &
python program2.py &
other programs ... &
lastProgram
Run Code Online (Sandbox Code Playgroud)

我运行它作为./myscript.sh

当我按Ctrl+C关闭它时lastProgram,它退出,所有其他程序继续在后台运行。问题是其他程序需要终止。

哪种方法可以正确处理从脚本启动的所有程序的关闭?

bash kill shell-script background-process

3
推荐指数
1
解决办法
8513
查看次数

标签 统计

background-process ×1

bash ×1

kill ×1

shell-script ×1