This commit is contained in:
unigeorge 2021-10-07 10:50:07 +08:00 committed by GitHub
parent d51d93db7a
commit b631fcf024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,15 +7,14 @@
[#]: publisher: " "
[#]: url: " "
Check Java processes on Linux with the jps command
使用 jps 命令监测 Linux 上的 Java 进程
======
With many processes running on a system, it's useful to have a quick way
to identify only Java with the jps command.
系统上会运行很多进程,使用 jps 命令快速识别 Java 进程是一个很有用的方法。
![Coffee beans][1]
On Linux, there are commands to view processes running on your system. A process is any ongoing event being managed by the kernel. A process is spawned when you launch an application, but there are also many other processes running in the background of your computer, including programs to keep your system time accurate, to monitor for new filesystems, to index files, and more. The utilities, such as those included in the [procps-ng package][2], that monitor these processes tend to be intentionally generic. They look at all processes on your computer so you can filter the list based on what you need to know.
在 Linux 上,有一些命令可以用于查看系统上运行的进程。进程是指的是由内核管理的正在进行的事件。每当启动应用程序时,就会产生一个进程,但也有许多进程在计算机后台运行,像保持系统时间准确的程序、监视新文件系统的程序、索引化文件的程序等。有一些实用程序可以用来监测这些进程,比如包含在 [procps-ng 包][2] 中的那些程序,但它们往往都是对各种进程通用的。它们会查看计算机上的所有进程,你可以根据想要的内容来过滤结果列表。
On Linux, you can view processes with the `ps` command. It is the simplest way to view the running processes on your system.
在 Linux 上,可以使用 `ps` 命令查看进程。这是查看系统上正在运行的进程的最简单方法。
```
@ -25,7 +24,7 @@ $ ps
  66930 pts/0    00:00:00 ps
```
You can use the `ps` command to view running Java processes on a system also by piping output to `grep`.
你也可以使用 `ps` 命令,将结果输出到管道符 `grep`,从而查看系统上运行的 Java 进程,。
```
@ -33,9 +32,9 @@ $ ps ax |grep java
  67604 pts/1    Sl+    0:18 /usr/lib/jvm/java-11-openjdk-11.0.12.0.7-4.fc34.x86_64/bin/java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED -Dorg.jboss.boot.log.file=/home/alan/wildfly/24.0.1/standalone/log/server.log -Dlogging.configuration=file:/home/alan/wildfly/24.0.1/standalone/configuration/logging.properties -jar /home/alan/wildfly/24.0.1/jboss-modules.jar -mp /home/alan/wildfly/24.0.1/modules org.jboss.as.standalone -Djboss.home.dir=/home/alan/wildfly/24.0.1 -Djboss.server.base.dir=/home/alan/wildfly/24.0.1/standalone
```
OpenJDK, however, has its very own specific process monitor. The Java Virtual Machine Process Status (jps) tool allows you to scan for each running instance of the Java Virtual Machine (JVM) on your system.
然而OpenJDK 有自己的特定进程监视器。Java 虚拟机进程状态 (jps) 工具可以帮你扫描系统上每个运行的 Java 虚拟机 (JVM) 实例。
To view a similar output as seen in the `ps` command, use the `-v` option. This is useful, partly because it requires less typing.
要想实现与 `ps` 命令类似的输出,可以使用 `-v` 选项。这很实用,因为与 `ps` 相比,它可以减少你的输入。
```
@ -43,7 +42,7 @@ $ jps -v
67604 jboss-modules.jar -D[Standalone] -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED -Dorg.jboss.boot.log.file=/home/alan/wildfly/24.0.1/standalone/log/server.log -Dlogging.configuration=file:/home/alan/wildfly/24.0.1/standalone/configuration/logging.properties
```
The default `jps` output provides the process identifier and the class name or Jar file name of each detected instance.
`jps` 的默认输出会给出每个检测到的实例的进程标识符,以及类名或 Jar 文件名。
```
@ -52,9 +51,9 @@ $ jps
69430 Jps
```
**Note:** The man page for `jps` states that it is experimental and unsupported. Still, it's a nice-to-have option because often many processes are running on a system, and having a quick way to identify only Java is useful.
**注意:** `jps` 的手册页指出此命令是试验性且不受支持的。尽管如此,它仍然是一个不错的选择,因为通常一个系统上运行着许多进程,有这样一种只识别 Java 进程的快速方法是很有用的。
Because Java is still a popular language today, being familiar with the Java Development Kit and Runtime Environment remains important. They contain many tools applicable to the development and maintenance of Java applications.
当下的 Java 仍然是一种流行的语言,所以熟悉 Java 开发工具包和运行时环境仍然很重要。它们里面包含着许多适用于 Java 应用程序开发和维护的工具。
--------------------------------------------------------------------------------