gpt4 book ai didi

linux - 如果bash脚本开始超时,如何退出?

转载 作者:太空宇宙 更新时间:2023-11-04 05:10:38 25 4
gpt4 key购买 nike

我使用超时功能运行脚本

timeout 86400 ./start.sh

如何在超时倒计时之前终止脚本?Ctr+C 在这种情况下不起作用关闭终端仍将进程留在后台

这是我的完整脚本:

python3 startmeVtest.py 5 2 10
timeout 86400 ./start.sh
sleep 4
python3 startmeVtest.py 10 4 20
timeout 86400 ./start.sh
sleep 4
python3 startmeVtest.py 20 4 40
timeout 86400 ./start.sh
sleep 4
python3 startmeVtest.py 30 8 50
timeout 86400 ./start.sh
sleep 4
python3 startmeVtest.py 50 9 70
./start.sh
exit 0

我想在 bash 脚本完成之前退出它,而不是一直使用 ps -A。

最佳答案

使用 grep 按名称查找进程列表

pgrep timeout

按名称杀死所有进程

pkill timeout 

关于linux - 如果bash脚本开始超时,如何退出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55828876/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com