1, JPS Introduction
Used to view the specific state of all Java processes that have access to the hotspot-based JVM, including the process ID, the path of the process startup, and the startup parameters, similar to the PS on Unix, except that JPS is used to display the Java process, and that JPS can be understood as a subset of PS.
When using JPS, if no hostid is specified, it will only display all Java processes in the local environment, and if HostID is specified, it will display the Java process above the specified HostID, but this requires a JSTATD service on the remote service. You can see the previous JSTATD section to start the Jstad service.
2. Command format
JPS [Options] [HostID]
3. Common parameter description
-Q ignores the output's class name, jar name, and parameters passed to the main method, only outputs the PID.
The-m output is passed to the main method parameter, and if it is an inline JVM, the output is null.
-L OUTPUT The full package name of the application main class, or the full path to the application jar file.
-V output passed to the JVM parameters.
-V Outputs the parameters (. hotspotrc files, or files specified by parameter-xx:flags=) passed to the JVM by the tagged file.
-j is used to pass the JVM option to the Java loader called by Javac, for example, "-j-xms48m" sets the boot memory to 48M, and the-J option makes it easy to pass parameters to the underlying virtual machine application based on Java development.
4. Server identification
HOSTID Specifies the target server, which has the following syntax:
[Protocol:] [[//]hostname] [:p ORT] [/ServerName]
Protocol-if protocol and hostname are not specified, that represents the local protocol associated with the current environment, and if hostname is specified and no protocol is specified, then the default for protocol is RMI.
Hostname-the IP or name of the server, not specified, indicates the native.
Port-The ports of the remote RMI, which defaults to 1099 if not specified.
Servername-Name of the JSTATD registered in the RMI registry.
5. Examples of Use
5.1. List The local Java process
Without any parameters
[Email protected]:~$ JPS 11644 Main 1947 12843 Jps |
With-v parameter
[Email protected]:~$ jps-v 11644 MAIN-AGENTLIB:JDWP=TRANSPORT=DT_SOCKET,SUSPEND=Y,ADDRESS=LOCALHOST:43467-DFILE.ENCODING=GBK 1947-dosgi.requiredjavaversion=1.5-xx:maxpermsize=256m-xms40m-xmx512m 12858 jps-denv.class.path=/home/fenglibin/java6/lib/dt.jar:/home/fenglibin/java6/lib/tools.jar::/usr/bin/ Libtool:/usr/bin/autoconf:/usr/local/berkeleydb.4.8/lib-dapplication.home=/home/fenglibin/java6-xms8m |
With-l parameter
[Email protected]:~$ jps-l 11644 Com.alibaba.china.webww.core.Main 12870 Sun.tools.jps.Jps 1947 |
5.2. List remote Java processes
In the JSTATD chapter, we have passed:
Rmiregistry 2020&jstatd-j-djava.security.policy=all.policy-p 2020-n Alternatejstatdservername |
The JSTATD service named Alternatejstatdservername is started, and we can now list the Java processes to which it has access by using the service.
[Email protected]:~$ JPS 10.1.1.234:2020/alternatejstatdservername 29556 Bootstrap 28671 Wsprelauncher 2602 Registryimpl 18272 Test 2603 JSTATD |
PS-EF viewing the active process
PS-EF |grep ABC view activity process with "ABC"
PS-EF |grep-v ABC to view activity processes that do not contain ABC
1) PS A shows all the programs under the current terminal, including other users ' programs.
2) ps-a Show All Programs.
3) PS C lists the program, displays the actual instruction name of each program, and does not include the path, parameter or the indication of the resident service.
4) Ps-e The effect of this parameter is the same as specifying the "A" parameter.
5) When listing the program, PS e displays the environment variables used by each program.
6) PS F Displays the tree structure with ASCII characters, expressing the relationship between the programs.
7) ps-h shows the tree structure, indicating the relationship between the programs.
8) Ps-n shows all the programs except the program under the PS Command Terminal.
9) PS s uses the program signal format to display the program status.
PS S when listing programs, including interrupted sub-program data.
One) ps-t< terminal number >
Specify the terminal number and list the status of the program that belongs to the terminal.
PS u
Displays the status of the program in a user-oriented format.
PS X
Show All programs, do not differentiate by terminal.
The most common approach is to Ps-aux, and then use a pipe symbol to direct to grep to find a specific process and then manipulate the specific process
The difference between the UNIX PS command and the JPS command