How do I kill this tomcat process in Terminal?

后端 未结 14 1552
渐次进展
渐次进展 2021-01-30 01:23

Using ps -ef | grep tomcat I found a tomcat server that is running. I tried kill -9 {id} but it returns \"No such process.\" What am I doing wrong?

相关标签:
14条回答
  • 2021-01-30 02:23

    As others already noted, you have seen the grep process. If you want to restrict the output to tomcat itself, you have two alternatives

    • wrap the first searched character in a character class

      ps -ef | grep '[t]omcat'
      

      This searches for tomcat too, but misses the grep [t]omcat entry, because it isn't matched by [t]omcat.

    • use a custom output format with ps

      ps -e -o pid,comm | grep tomcat
      

      This shows only the pid and the name of the process without the process arguments. So, grep is listed as grep and not as grep tomcat.

    0 讨论(0)
  • 2021-01-30 02:24

    I had to terminate activeMQ java process among many java processes on the server, and this one is started by the specific user (username is activemq). So good way of separating may be to start a process by a specific user :

    ps -ef | grep "activemq" | awk '{print $2}' | xargs kill -9
    
    0 讨论(0)
提交回复
热议问题