如何在unix中获取进程名称

时间:2016-12-12 10:41:22

标签: linux shell unix ps

如何列出除剩余详细信息之外的唯一进程名称。 输入以下命令后,我的输出低于输出值。

ps -ef | grep java



 oracle   103253 102843  1 Dec08 ?        01:11:23 /opt/oracle/jdk1.7.0_65/bin/java -server -Xms1024m -Xmx2048m -XX:PermSize=512m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=256m -Dweblogic.Name=oim_server1 -Djava.security.policy=/opt/oracle/products/oim/wlserver_10.3/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -Dweblogic.security.SSL.trustedCAKeyStore=/opt/oracle/products/oim/wlserver_10.3/server/lib/cacerts -DUseSunHttpHandler=true -da -Dplatform.home=/opt/oracle/products/oim/wlserver_10.3 -Dwls.home=/opt/oracle/products/oim/wlserver_10.3/server -Dweblogic.home=/opt/oracle/products/oim/wlserver_10.3/server -Dcommon.components.home=/opt/oracle/products/oim/oracle_common -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=/opt/oracle/servers/oim/weblogic/domains/oim -Djrockit.optfile=/opt/oracle/products/oim/oracle_common/modules/oracle.jrf_11.1.1/jrocket_optfile.txt -Doracle.server.config.dir=/opt/oracle/servers/oim/weblogic/domains/oim/config/fmwconfig/servers/oim_server1 -Doracle.domain.config.dir=/opt/oracle/servers/oim/weblogic/domains/oim/config/fmwconfig -Digf.arisidbeans.carmlloc=/opt/oracle/servers/oim/weblogic/domains/oim/config/fmwconfig/carml -Digf.arisidstack.home=/opt/oracle/servers/oim/weblogic/domains/oim/config/fmwconfig/arisidprovider -Doracle.security.jps.config=/opt/oracle/servers/oim/weblogic/domains/oim/config/fmwconfig/jps-config.xml -Doracle.deployed.app.dir=/opt/oracle/servers/oim/weblogic/domains/oim/servers/oim_server1/tmp/_WL_user -Doracle.deployed.app.ext=/- -Dweblogic.alternateTypesDirectory=/opt/oracle/products/oim/Oracle_IDM1/server/loginmodule/wls,/opt/oracle/products/oim/oracle_common/modules/oracle.ossoiap_11.1.1,/opt/oracle/products/oim/oracle_common/modules/oracle.oamprovider_11.1.1,/opt/oracle/products/oim/oracle_common/modules/oracle.jps_11.1.1 -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.common.classloaderurl.handler|oracle.fabric.common.uddiurl.handler|oracle.bpm.io.fs.protocol -Dweblogic.jdbc.remoteEnabled=false -Doracle.idm.ipf.home=/opt/oracle/products/oim/Oracle_IDM1//modules/oracle.idm.ipf_11.1.2 -Doracle.apm.home=/opt/oracle/products/oim/Oracle_IDM1/apm/ -DAPM_HELP_FILENAME=oesohwconfig.xml -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder -da:org.apache.xmlbeans... -DXL.HomeDir=/opt/oracle/products/oim/Oracle_IDM1/server -Dscheduler.disabled=false -Djava.security.auth.login.config=/opt/oracle/products/oim/Oracle_IDM1/server/config/authwl.conf -Dorg.owasp.esapi.resources=/opt/oracle/products/oim/Oracle_IDM1/server/apps/oim.ear/APP-INF/classes -DeditionOverride=ee -Djbo.ampool.doampooling=true -Djbo.ampool.minavailablesize=1 -Djbo.ampool.maxavailablesize=120 -Djbo.recyclethreshold=60 -Djbo.ampool.timetolive=-1 -Djbo.load.components.lazily=true -Djbo.doconnectionpooling=true -Djbo.txn.disconnect_level=1 -Djbo.connectfailover=false -Djbo.max.cursors=5 -Doracle.jdbc.implicitStatementCacheSize=5 -Doracle.jdbc.maxCachedBufferSize=19 -Dsoa.archives.dir=/opt/oracle/products/oim/Oracle_SOA1/soa -Dsoa.oracle.home=/opt/oracle/products/oim/Oracle_SOA1 -Dsoa.instance.home=/opt/oracle/servers/oim/weblogic/domains/oim -Dtangosol.coherence.clusteraddress=227.7.7.9 -Dtangosol.coherence.clusterport=9778 -Dtangosol.coherence.log=jdk -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Dweblogic.transaction.blocking.commit=true -Dweblogic.transaction.blocking.rollback=true -Djavax.net.ssl.trustStore=/opt/oracle/products/oim/wlserver_10.3/server/lib/DemoTrust.jks -Dem.oracle.home=/opt/oracle/products/oim/oracle_common -Djava.awt.headless=true -Dums.oracle.home=/opt/oracle/products/oim/Oracle_SOA1 -Xms1024m -Xmx2048m -XX:PermSize=512m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=256m -Dweblogic.management.discover=false -Dweblogic.management.server=t3://D09-DLV-OIAM01A.dev.clarient.local:7101 -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=/opt/oracle/products/oim/patch_wls1036/profiles/default/sysext_manifest_classpath:/opt/oracle/products/oim/patch_ocp371/profiles/default/sysext_manifest_classpath weblogic.Server
oracle   103348 103297  0 Dec08 ?        00:14:07 /opt/oracle/jdk1.7.0_65/bin/java -server -Xms256m -Xmx512m -XX:MaxPermSize=512m -Dweblogic.Name=oimclient_server1 -Djava.security.policy=/opt/oracle/products/oim/wlserver_10.3/server/lib/weblogic.policy -Dweblogic.ProductionModeEnabled=true -Dweblogic.security.SSL.trustedCAKeyStore=/opt/oracle/products/oim/wlserver_10.3/server/lib/cacerts -da -Dplatform.home=/opt/oracle/products/oim/wlserver_10.3 -Dwls.home=/opt/oracle/products/oim/wlserver_10.3/server -Dweblogic.home=/opt/oracle/products/oim/wlserver_10.3/server -Dcommon.components.home=/opt/oracle/products/oim/oracle_common -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=/opt/oracle/servers/oim/weblogic/domains/oim_client -Djrockit.optfile=/opt/oracle/products/oim/oracle_common/modules/oracle.jrf_11.1.1/jrocket_optfile.txt -Doracle.server.config.dir=/opt/oracle/servers/oim/weblogic/domains/oim_client/config/fmwconfig/servers/oimclient_server1 -Doracle.domain.config.dir=/opt/oracle/servers/oim/weblogic/domains/oim_client/config/fmwconfig -Digf.arisidbeans.carmlloc=/opt/oracle/servers/oim/weblogic/domains/oim_client/config/fmwconfig/carml -Digf.arisidstack.home=/opt/oracle/servers/oim/weblogic/domains/oim_client/config/fmwconfig/arisidprovider -Doracle.security.jps.config=/opt/oracle/servers/oim/weblogic/domains/oim_client/config/fmwconfig/jps-config.xml -Doracle.deployed.app.dir=/opt/oracle/servers/oim/weblogic/domains/oim_client/servers/oimclient_server1/tmp/_WL_user -Doracle.deployed.app.ext=/- -Dweblogic.alternateTypesDirectory=/opt/oracle/products/oim/oracle_common/modules/oracle.ossoiap_11.1.1,/opt/oracle/products/oim/oracle_common/modules/oracle.oamprovider_11.1.1,/opt/oracle/products/oim/oracle_common/modules/oracle.jps_11.1.1 -Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Dweblogic.jdbc.remoteEnabled=false -Dem.oracle.home=/opt/oracle/products/oim/oracle_common -Djava.awt.headless=true -Dweblogic.management.discover=false -Dweblogic.management.server=t3://D09-DLV-OIAM01A.dev.clarient.local:9101 -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -DXL.HomeDir=/opt/oracle/products/oim/Oracle_IDM1/designconsole -Djava.security.auth.login.config=/opt/oracle/products/oim/Oracle_IDM1/designconsole/config/authwl.conf -Djava.util.logging.config.file=/opt/oracle/servers/oim/weblogic/domains/oim_client/config/logging-oimclient_server1.properties -Dweblogic.ext.dirs=/opt/oracle/products/oim/patch_wls1036/profiles/default/sysext_manifest_classpath:/opt/oracle/products/oim/patch_ocp371/profiles/default/sysext_manifest_classpath:/opt/oracle/products/oim/Oracle_IDM1/designconsole/ext:/opt/oracle/products/oim/Oracle_IDM1/designconsole/lib -DUseSunHttpHandler=true weblogic.Server

我需要输出如下所述。

oracle   103253 102843  1 Dec08 ?        01:11:23 Name=oim_server1 
oracle   103348 103297  0 Dec08 ?        00:14:07  Name=oimclient_server1

1 个答案:

答案 0 :(得分:0)

您可以让sed删除剩余的详细信息。您也可以让ps -C来完成grep的工作。

ps -fCjava | sed "s'/opt/oracle/.*\(Name=[^ ]*\).*'\1'"