Linux remote Kill Process

Source: Internet
Author: User

Transfer from http://blog.csdn.net/tengdazhang770960436/article/details/53906263

First step: Get the process number
" ps-ef | grep ${tomcat_name} | grep-v grep | awk  ' {print $} '"'{print $}' )
Step two: Kill the process
" kill-9 ${pid} "
Attention:

Killing the remote process is not the same as killing the local process, killing the local process requires just one word:

Ps-ef | grep ${tomcat_name} | Grep-v grep | awk  '{print $}'|xargs Kill-9

But the process of killing the remote is different, because the filtered results are returned as a whole, if the command to kill the process is executed remotely:

" ps-ef | grep ${tomcat_name} | grep-v grep | awk  ' {print $} ' | Xargs  kill-9'

You will get the wrong hint:

Kill Process Java-jar tomcat-8081Kill:can't find process "root"Kill:can't find process "09:42"Kill:can't find process "?"Kill:can't find process "00:00:44"Kill:can't find process "/opt/tools/jdk1.7.0_67/bin/java"Kill:can't find process "-djava.util.logging.config.file=/opt/tools/tomcat-8081/conf/logging.properties"Kill:can't find process "-djava.util.logging.manager=org.apache.juli.classloaderlogmanager"Kill:can't find process "-DDISCONF.ENV=RD"Kill:can't find process "-ddisconf.conf_server_host=192.168.100.15:8015"Kill:can't find process "-ddisconf.app=ync365"Kill:can't find process "-ddisconf.version=1.0.0"Kill:can't find process "-ddisconf.user_define_download_dir=./classes"Kill:can't find process "-ddisconf.enable.remote.conf=true"Kill:can't find process "-djdk.tls.ephemeraldhkeysize=2048"Kill:can't find process "-djava.endorsed.dirs=/opt/tools/tomcat-8081/endorsed"Kill:can't find process "-classpath"Kill:can't find process "/opt/tools/tomcat-8081/bin/bootstrap.jar:/opt/tools/tomcat-8081/bin/tomcat-juli.jar"Kill:can't find process "-dcatalina.base=/opt/tools/tomcat-8081"Kill:can't find process "-dcatalina.home=/opt/tools/tomcat-8081"Kill:can't find process "-djava.io.tmpdir=/opt/tools/tomcat-8081/temp"Kill:can't find process "org.apache.catalina.startup.Bootstrap"Kill:can't find process "start"

This is because the remote command you are executing returns the following result:

Root7314     1  7  the:Wuyipts/0    xx:xx: -/opt/tools/jdk1.7.0_67/bin/java-djava.util.logging.config.file=/opt/tools/apache-tomcat-7.0. -/conf/logging.properties-djava.util.logging.manager=org.apache.juli.classloaderlogmanager- Djdk.tls.ephemeraldhkeysize=2048-djava.endorsed.dirs=/opt/tools/apache-tomcat-7.0. -/endorsed-classpath/opt/tools/apache-tomcat-7.0. -/bin/bootstrap.jar:/opt/tools/apache-tomcat-7.0. -/bin/tomcat-juli.jar-dcatalina.Base=/opt/tools/apache-tomcat-7.0. --dcatalina.home=/opt/tools/apache-tomcat-7.0. --djava.io.tmpdir=/opt/tools/apache-tomcat-7.0. -/temp org.apache.catalina.startup.Bootstrap Start

Then Xargs kill-9 will delete all of the above spaces separated process, in fact they are not process, just a description of the process returned below, we really need the process number is the second 7314 this process, so we need to filter back the string again, This will give you a real process number.

Linux remote Kill Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.