Linux脚本杀死Java进程

Linux脚本杀死Java进程

问题描述:

我希望linux脚本杀死控制台上运行的Java程序.

I want linux script to kill java program running on console.

以下是作为jar运行的进程.

Following is the process running as jar.

[rapp@s1-dlap0 ~]$ ps -ef |grep java
rapp    9473    1  0 15:03 pts/1    00:00:15 java -jar wskInterface-0.0.1-SNAPSHOT-jar-with-dependencies.jar
rapp   10177  8995  0 16:00 pts/1    00:00:00 grep java
[rapp@s1-dlap0 ~]$

您可以像这样简单地使用pkill -f:

You can simply use pkill -f like this:

pkill -f 'java -jar'

要杀死运行您特定jar的特定Java进程,请使用基于regex的pkill命令:

To kill a particular java process running your specific jar use this regex based pkill command:

pkill -f 'java.*lnwskInterface'