[英]How do I kill all tasks run by a bash file in a screen window?
Perhaps the answer is already out there, but after reading several Questions i didn't manage to do what I need. 也许答案已经存在,但在阅读了几个问题后,我无法做到我需要做的事情。
My situation: I am using a machine through ssh
. 我的情况:我通过
ssh
使用机器。 I created a screen
window, I called a bash
file like the following: 我创建了一个
screen
窗口,我调用了一个bash
文件,如下所示:
for var in 1..N
do
java -option $var
done
with N
very high. N
非常高。
Question: Is there a way to kill the all the java tasks launched by the bash
file at once? 问题:有没有办法一次性杀死
bash
文件启动的所有java任务? Or to kill the screen window and everything is running in the screen? 或者杀死屏幕窗口,一切都在屏幕上运行?
Note : The java
tasks are running -inside the screen
- in the foreground. 注意 :
java
任务正在运行 - 在screen
- 在前台。 If I try to do CTRL-C
I can kill only one java
task at the time. 如果我尝试做
CTRL-C
我当时只能杀死一个java
任务。
For example: 例如:
Put screen
in the background ( Ctrl-Alt + D
) 将
screen
放在后台( Ctrl-Alt + D
)
List your open screen sessions: 列出您的开放屏幕会话:
screen -ls
You'll get something like: 你会得到类似的东西:
There is a screen on:
2222.pts-3.yourmachine (Detached)
The first number is the process ID of the screen session. 第一个数字是屏幕会话的进程ID。
Use this number to kill the screen and all its childs: 使用此数字可以杀死屏幕及其所有子节点:
PID=2222
kill $PID
If your java application catches some signals, use a less graceful way to kill them, eg kill -9 $PID
如果您的java应用程序捕获一些信号,请使用不太优雅的方法来杀死它们,例如
kill -9 $PID
如果你不害怕杀死任何正在运行的java进程你可以做总是有用的“killall -9 java”:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.