[英]How to exit from bash script if it started with timeout?
I run my scripts with timeout function我使用超时功能运行我的脚本
timeout 86400 ./start.sh
How can I terminate script before timeout counted down?如何在超时倒计时之前终止脚本? Ctr+C does not work in this case Closing terminal still leaves process on background
在这种情况下,Ctr+C 不起作用关闭终端仍将进程留在后台
This is my full script:这是我的完整脚本:
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
I would like to exit from my bash script before it finish without using ps -A all the time.我想在我的 bash 脚本完成之前退出,而不是一直使用 ps -A。
find a list of processes by name using grep使用 grep 按名称查找进程列表
pgrep timeout
kill all processes by name按名称杀死所有进程
pkill timeout
下面将直接杀死你的 start.sh 脚本
pkill -f "start.sh"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.