运行ps
命令时,我得到如下输出:
[nick]$ ps
PID TTY TIME CMD
3287 pts/3 00:00:00 bash
12308 pts/3 00:00:00 ps
19544 pts/3 00:00:00 STS
19548 pts/3 00:45:25 java
19753 pts/3 00:04:10 java
21149 pts/3 00:15:25 java
这对我没有多大帮助,因为我不知道每个 Java 进程到底是什么。跑步ps T
提供了更多信息,但现在信息太多了!
[nick]$ ps T
PID TTY STAT TIME COMMAND
3287 pts/3 Ss 0:00 bash
12319 pts/3 R+ 0:00 ps T
19544 pts/3 S 0:00 /home/nick/springsource/sts-3.0.0.RELEASE/STS
19548 pts/3 Sl 45:25 /usr/lib/jvm/java-6-openjdk-amd64/bin/java -Dosgi.requiredJavaVersion=1.5 -Xms256m -Xmx1536m -XX:MaxPermSize=512m -jar /home/nick/springsource/sts-3.0.0.RELEASE//plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar -os linux -w......
19753 pts/3 Sl 4:10 /usr/lib/jvm/java-6-openjdk-amd64/bin/java -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:48135 -Dcatalina.base=/home/nick/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp3 -Dcatalina.home=/home/nic......
21149 pts/3 Sl 15:25 /usr/lib/jvm/java-6-openjdk-amd64/bin/java -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:57346 -Dcatalina.base=/home/nick/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp5 -Dcatalina.home=/home/nic......
有没有办法只显示正在运行的 Java 包或类的文件名?像这样的东西:
[nick]$ ps
PID TTY TIME CMD
3287 pts/3 00:00:00 bash
12308 pts/3 00:00:00 ps
19544 pts/3 00:00:00 STS
19548 pts/3 00:45:25 java abc.jar
19753 pts/3 00:04:10 java def.java
21149 pts/3 00:15:25 java ghi.jar
如果这不能通过ps
参数来完成,有没有办法实现它grep
?