我有这个命令:
ps -C java -o pid=,%mem=,vsz=,%cpu=,command=
产生以下输出:
2982 5.0 12313368 11.3 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -Dname=kafka_broker -Xmx1G -Xms384M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:Initia
3296 0.7 4150868 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -Dname=zookeeper -Xmx512M -Xms512M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:Initiatin
9067 3.7 5889540 15.7 java -Dname=eq_engine -Dlogback.configurationFile=/eq/equalum/eql-server-0.4.1.0-SNAPSHOT/conf/engine_logback.xml -Xmx2G -Xms256M -Xss384K -server -Djava.security
9308 5.1 4895240 1.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9378 2.2 4745848 0.2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9379 2.1 4745848 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9380 2.2 4745848 0.2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9387 2.1 4745848 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9418 2.0 4745848 0.2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9421 1.9 4745848 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9448 2.0 4680312 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/equalum/eql-server-0.4.1.0-SNAPSHOT/eql-job-server/lib/*:/eq/spark/spark-2.2.0-bin-ha
9853 3.2 5800672 1.5 java -Dname=eq_agent -Djava.security.egd=file:///dev/urandom -server -Xmx2G -Xms256M -Xss384K -jar /eq/equalum/eqagent-0.4.1.0-SNAPSHOT/lib/eql_agent-0.4.1.0-SNAPS
124895 2.0 2896252 0.2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -Dproc_namenode -Xmx1000m -Djava.net.preferIPv4Stack=true -Dhadoop.log.dir=/eq/hadoop/logs -D
125728 3.4 4788960 0.3 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/spark/spark-2.2.0-bin-hadoop2.7/conf/:/eq/spark/spark-2.2.0-bin-hadoop2.7/jars/* -Dsp
125831 2.3 4417984 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/spark/spark-2.2.0-bin-hadoop2.7/conf/:/eq/spark/spark-2.2.0-bin-hadoop2.7/jars/* -Dsp
125905 3.0 4833676 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/spark/spark-2.2.0-bin-hadoop2.7/conf/:/eq/spark/spark-2.2.0-bin-hadoop2.7/jars/* -Dsp
125986 3.6 4833952 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -cp /eq/spark/spark-2.2.0-bin-hadoop2.7/conf/:/eq/spark/spark-2.2.0-bin-hadoop2.7/jars/* -Dsp
126254 1.7 2882876 0.1 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -Dproc_datanode -Xmx1000m -Djava.net.preferIPv4Stack=true -Dhadoop.log.dir=/eq/hadoop/logs -D
126432 2.4 2858676 0.0 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/bin/java -Dproc_secondarynamenode -Xmx1000m -Djava.net.preferIPv4Stack=true -Dhadoop.log.dir=/eq/hadoop
我正在尝试获取特定的java进程,但是我得到了所有java进程,我只想获得一个特定的进程。如何更改命令来执行此操作?
答案 0 :(得分:1)
一旦你有了pid(9067)
ps -p 9067 -o pid=,%mem=,vsz=,%cpu=,command=
编辑,因为我刚刚复制了来自问题的命令我没有注意到有很多=
,最后只能有一个=
,它是删除标题
ps -p 9067 -o pid,%mem,vsz,%cpu,command
ps -p 9067 -o pid,%mem,vsz,%cpu,command=
man ps
了解更多信息
答案 1 :(得分:0)
快速方式 - 使用grep:
ps -C java -o pid=,%mem=,vsz=,%cpu=,command= |grep SNAPSHOT/conf/engine_logback.xml
享受