捕获进程ID并将其删除的最简单方法是什么?
当我输入ps -ef | grep wso2
时,我得到以下内容。我需要捕获第一个进程ID并在一个命令中终止它。
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
答案 0 :(得分:2)
通过id杀死进程的最简单方法(如果你想杀死java进程)是
kill `jps | grep wso2 | awk '{ print $1 }'`
jps - 列出目标系统上的已检测Java虚拟机(JVM)
详细信息 - man jps