How can I list all Java processes in bash?
I need an command line. I know there is command ps
but I don\'t know what parameters I need to use.
To know the list of java running on the linux machine. ps -e | grep java
When I want to know if a certain Java class is getting executed, I use the following command line:
ps ww -f -C java | grep "fully.qualified.name.of.class"
From the OS side view, the process's command name is "java". The "ww" option widens the colum's maximum characters, so it's possible to grep the FQN of the related class.
Starting from Java 7, the simplest way and less error prone is to simply use the command jcmd
that is part of the JDK such that it will work the same way on all OS.
Example:
> jcmd
5485 sun.tools.jcmd.JCmd
2125 MyProgram
jcmd
allows to send diagnostic command requests to a running Java Virtual Machine (JVM).
More details about how to use jcmd.
See also the jcmd Utility
ps aux | grep java
or
$ ps -fea|grep -i java
If I want simply list java processes, use:
ps -A | grep java
Recent Java comes with Java Virtual Machine Process Status Tool "jps"
http://download.oracle.com/javase/1.5.0/docs/tooldocs/share/jps.html
For example,
[nsushkin@fulton support]$ jps -m
2120 Main --userdir /home/nsushkin/.netbeans/7.0 --branding nb
26546 charles.jar
17600 Jps -m