查找java进程(Linux )(范例)的简单方法

・3 分钟阅读

如果你想要"杀死"一个java进程,你可能想知道进程标识符(PID ),因此你必须了解PID (Linux ),


$ ps -fea|grep -i java

user 2895 8191 0 09:28 pts/1 00:00:00 grep -i java
user 4610 4607 1 Aug29 ? 01:40:00 /home/user/Software/java-7-sun/bin/java -Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx768m -XX:MaxPermSize=256m -jar /home/user/Software/springsource/sts-3.3.0.RELEASE//plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar -os linux -ws gtk -arch x86_64 -showsplash -launcher /home/user/Software/springsource/sts-3.3.0.RELEASE/STS -name STS --launcher.library /home/user/Software/springsource/sts-3.3.0.RELEASE//plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20130521-0416/eclipse_1506.so -startup /home/user/Software/springsource/sts-3.3.0.RELEASE//plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar --launcher.overrideVmargs -exitdata 518012 -product org.springsource.sts.ide -vm /home/user/Software/java-7-sun/bin/java -vmargs -Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx768m -XX:MaxPermSize=256m -jar /home/user/Software/springsource/sts-3.3.0.RELEASE//plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.ja

第一列是运行进程的用户,第二列PID

因此,如果你想杀死java进程(在本示例中为STS/Eclipse ),你必须执行以下操作:

$ kill -9 4610 #or any signal that you need

执行这个操作的最简单方法是使用jps命令(java虚拟机进程状态工具):


$ jps

4610 org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
2952 Jps

是相同的信息,但只是JVM进程,没有更多的信息,只是必要的。

如果需要更多信息,请使用此参数(完整软件包名称)运行:


$ jps -l 

4610 /home/pcollaog/Software/springsource/sts-3.3.0.RELEASE//plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
3025 sun.tools.jps.Jps

jvm参数


$ jps -v

4610 org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar -Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx768m -XX:MaxPermSize=256m
3157 Jps -Dapplication.home=/home/pcollaog/Software/jdk1.6.0_43 -Xms8m

第一列是JVM,所以,你可以"kill"掉它了。

best regards

Xn_warm profile image