简体   繁体   中英

What's the easiest way to capture a process ID and kill it?

What's the easiest way to capture a process ID and kill it?

When I type ps -ef | grep wso2 ps -ef | grep wso2 I get the following. I need to capture the first process ID and kill it in one command.

ubuntu    5460     1  4 08:38 pts/5    00:01:15 /usr/lib/jvm/jdk1.7.0_79//bin/java -Xbootclasspath/a: -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/logs/heap-dump.hprof -Dcom.sun.management.jmxremote -classpath /usr/lib/jvm/jdk1.7.0_79//lib/tools.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/bin/org.wso2.carbon.bootstrap-4.4.1.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/bin/tcpmon-1.0.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/bin/tomcat-juli-7.0.59.jar:/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/commons-lang-2.6.0.wso2v1.jar -Djava.endorsed.dirs=/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/endorsed:/usr/lib/jvm/jdk1.7.0_79//jre/lib/endorsed:/usr/lib/jvm/jdk1.7.0_79//lib/endorsed -Djava.io.tmpdir=/home/ubuntu/UES/wso2ues-2.0.0-m4/tmp -Dcatalina.base=/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/tomcat -Dwso2.server.standalone=true -Dcarbon.registry.root=/ -Djava.command=/usr/lib/jvm/jdk1.7.0_79//bin/java -Dcarbon.home=/home/ubuntu/UES/wso2ues-2.0.0-m4 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/conf -Djava.util.logging.config.file=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/conf/etc/logging-bridge.properties -Dcomponents.repo=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/components/plugins -Dconf.location=/home/ubuntu/UES/wso2ues-2.0.0-m4/repository/conf -Dcom.atomikos.icatch.file=/home/ubuntu/UES/wso2ues-2.0.0-m4/lib/transactions.properties -Dcom.atomikos.icatch.hide_init_file_path=true -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Djava.security.egd=file:/dev/./urandom -Dfile.encoding=UTF8 -Djava.net.preferIPv4Stack=true -Dcom.ibm.cacheLocalHost=true -DworkerNode=false org.wso2.carbon.bootstrap.Bootstrap
ubuntu    5725  4327  0 09:05 pts/5    00:00:00 tail -1000f ../repository/logs/wso2carbon.log
ubuntu    5727  2159  0 09:06 pts/3    00:00:00 grep --color=auto wso2

Esiest way to kill process by id (if you want to kill java process) is

kill `jps | grep wso2 | awk '{ print $1 }'`

jps - Lists the instrumented Java Virtual Machines (JVMs) on the target system

Detailed info - man jps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM