如何在终端中杀死这个tomcat进程?

时间:2022-06-11 06:55:01

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?

使用ps -ef | grep tomcat,我找到了一个正在运行的tomcat服务器。我试过kill -9 {id},但它返回“没有这样的过程”。我做错了什么?

Here's an example:

这里有一个例子:

Admins-MacBook-Pro:test-parent tom.maxwell$ ps -ef | grep tomcat
2043706342 39707 39695   0  3:40PM ttys000    0:00.00 grep tomcat
Admins-MacBook-Pro:test-parent tom.maxwell$ kill -9 39707
-bash: kill: (39707) - No such process

13 个解决方案

#1


88  

There is no need to know Tomcat's pid (process ID) to kill it. You can use the following command to kill Tomcat:

不需要知道Tomcat的pid(进程ID)来杀死它。可以使用以下命令杀死Tomcat:

pkill -9 -f tomcat

#2


21  

ps -ef | grep tomcat | awk '{print $2}' | xargs kill -9

| grep tomcat | awk '{print $2}' | xargs kill -9。

https://gist.github.com/nrshrivatsan/1d2ea4fcdcb9d1857076

https://gist.github.com/nrshrivatsan/1d2ea4fcdcb9d1857076

Part 1

第1部分

ps -ef | grep tomcat => Get all processes with tomcat grep

pb0 grep tomcat =>用tomcat grep获取所有进程。

Part 2

第2部分

Once we have process details, we pipe it into the part 2 of the script

一旦我们有了流程细节,我们就把它导入脚本的第2部分。

awk '{print $2}' | xargs kill -9 => Get the second column [Process id] and kill them with -9 option

打印$2}' | xargs kill -9 =>获得第二列[进程id]并使用-9选项杀死它们。

Hope this helps.

希望这个有帮助。

#3


18  

Tomcat is not running. Your search is showing you the grep process, which is searching for tomcat. Of course, by the time you see that output, grep is no longer running, so the pid is no longer valid.

Tomcat没有运行。您的搜索显示了grep进程,它正在搜索tomcat。当然,当您看到输出时,grep不再运行,因此pid不再有效。

#4


12  

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

正如其他人已经注意到的,您已经看到了grep过程。如果您想将输出限制为tomcat本身,那么您有两个选择。

  • 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.

    这也是对tomcat的搜索,但是忽略了grep [t]omcat条目,因为它不匹配[t]omcat。

  • use a custom output format with ps

    使用带有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.

    这只显示了没有流程参数的pid和进程的名称。因此,grep被列为grep而不是grep tomcat。

#5


9  

just type the below command in terminal

在终端中键入下面的命令。

ps -ef |grep 'catalina'

copy the value of process id then type the following command and paste process id

复制进程id的值然后键入下面的命令和粘贴进程id。

 kill -9 processid

#6


2  

ps -ef

will list all your currently running processes

将列出当前运行的所有进程?

| grep tomcat

will pass the output to grep and look for instances of tomcat. Since the grep is a process itself, it is returned from your command. However, your output shows no processes of Tomcat running.

将输出传递给grep并查找tomcat的实例。由于grep是一个进程本身,所以它从您的命令返回。但是,您的输出显示没有Tomcat运行的进程。

#7


1  

ps -Af | grep "tomcat" | grep -v grep | awk '{print$2}' | xargs kill -9

#8


0  

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 :

我必须在服务器上的许多java进程中终止activeMQ java进程,而这个是由特定的用户启动的(用户名是activeMQ)。因此,好的分离方法可能是由一个特定的用户开始一个过程:

ps -ef | grep "activemq" | awk '{print $2}' | xargs kill -9

#9


0  

This worked for me:

这工作对我来说:

Step 1 : echo ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'

步骤1:echo ps aux | grep org.apache.catalina.startup。Bootstrap | grep -v grep | awk '{print $2}

This above command return "process_id"

上面的命令返回“process_id”

Step 2: kill -9 process_id
// This process_id same as Step 1: output

步骤2:kill -9 process_id //这个process_id与步骤1相同:输出。

#10


0  

as @Aurand to said, tomcat is not running. you can use the

正如@Aurand所说,tomcat没有运行。您可以使用

ps -ef |grep java | grep tomcat command to ignore the ps programs.

p -ef | java |grep tomcat命令可以忽略ps程序。

worked for me in the shell scripte files.

在shell脚本文件中为我工作。

#11


0  

In tomcat/bin/catalina.sh

在tomcat / bin / catalina.sh

add the following line after just after the comment section ends:

在评论部分结束后添加以下行:

CATALINA_PID=someFile.txt

then, to kill a running instance of Tomcat, you can use:

然后,为了杀死Tomcat的运行实例,您可以使用:

kill -9 `cat someFile.txt`

#12


0  

kill -9 $(ps -ef | grep 8084 | awk 'NR==2{print $2}')

NR is for the number of records in the input file. awk can find or replaces text

NR是用于输入文件中的记录数。awk可以查找或替换文本。

#13


0  

To kill a process by name I use the following

我使用下面的名称来杀死一个进程。

ps aux | grep "search-term" | grep -v grep | tr -s " " | cut -d " " -f 2 | xargs kill -9

“搜索词”| grep -v grep -v grep | tr -s " | cut -d " - f2 | xargs kill -9。

The tr -s " " | cut -d " " -f 2 is same as awk '{print $2}'. tr supressess the tab spaces into single space and cut is provided with <SPACE> as the delimiter and the second column is requested. The second column in the ps aux output is the process id.

tr -s " " | cut -d " " - f2与awk '{print $2}相同。tr将标签空间插入到单个空格中,并以< space >作为分隔符,并请求第二列。辅助输出的第二列是进程id。

#1


88  

There is no need to know Tomcat's pid (process ID) to kill it. You can use the following command to kill Tomcat:

不需要知道Tomcat的pid(进程ID)来杀死它。可以使用以下命令杀死Tomcat:

pkill -9 -f tomcat

#2


21  

ps -ef | grep tomcat | awk '{print $2}' | xargs kill -9

| grep tomcat | awk '{print $2}' | xargs kill -9。

https://gist.github.com/nrshrivatsan/1d2ea4fcdcb9d1857076

https://gist.github.com/nrshrivatsan/1d2ea4fcdcb9d1857076

Part 1

第1部分

ps -ef | grep tomcat => Get all processes with tomcat grep

pb0 grep tomcat =>用tomcat grep获取所有进程。

Part 2

第2部分

Once we have process details, we pipe it into the part 2 of the script

一旦我们有了流程细节,我们就把它导入脚本的第2部分。

awk '{print $2}' | xargs kill -9 => Get the second column [Process id] and kill them with -9 option

打印$2}' | xargs kill -9 =>获得第二列[进程id]并使用-9选项杀死它们。

Hope this helps.

希望这个有帮助。

#3


18  

Tomcat is not running. Your search is showing you the grep process, which is searching for tomcat. Of course, by the time you see that output, grep is no longer running, so the pid is no longer valid.

Tomcat没有运行。您的搜索显示了grep进程,它正在搜索tomcat。当然,当您看到输出时,grep不再运行,因此pid不再有效。

#4


12  

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

正如其他人已经注意到的,您已经看到了grep过程。如果您想将输出限制为tomcat本身,那么您有两个选择。

  • 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.

    这也是对tomcat的搜索,但是忽略了grep [t]omcat条目,因为它不匹配[t]omcat。

  • use a custom output format with ps

    使用带有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.

    这只显示了没有流程参数的pid和进程的名称。因此,grep被列为grep而不是grep tomcat。

#5


9  

just type the below command in terminal

在终端中键入下面的命令。

ps -ef |grep 'catalina'

copy the value of process id then type the following command and paste process id

复制进程id的值然后键入下面的命令和粘贴进程id。

 kill -9 processid

#6


2  

ps -ef

will list all your currently running processes

将列出当前运行的所有进程?

| grep tomcat

will pass the output to grep and look for instances of tomcat. Since the grep is a process itself, it is returned from your command. However, your output shows no processes of Tomcat running.

将输出传递给grep并查找tomcat的实例。由于grep是一个进程本身,所以它从您的命令返回。但是,您的输出显示没有Tomcat运行的进程。

#7


1  

ps -Af | grep "tomcat" | grep -v grep | awk '{print$2}' | xargs kill -9

#8


0  

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 :

我必须在服务器上的许多java进程中终止activeMQ java进程,而这个是由特定的用户启动的(用户名是activeMQ)。因此,好的分离方法可能是由一个特定的用户开始一个过程:

ps -ef | grep "activemq" | awk '{print $2}' | xargs kill -9

#9


0  

This worked for me:

这工作对我来说:

Step 1 : echo ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'

步骤1:echo ps aux | grep org.apache.catalina.startup。Bootstrap | grep -v grep | awk '{print $2}

This above command return "process_id"

上面的命令返回“process_id”

Step 2: kill -9 process_id
// This process_id same as Step 1: output

步骤2:kill -9 process_id //这个process_id与步骤1相同:输出。

#10


0  

as @Aurand to said, tomcat is not running. you can use the

正如@Aurand所说,tomcat没有运行。您可以使用

ps -ef |grep java | grep tomcat command to ignore the ps programs.

p -ef | java |grep tomcat命令可以忽略ps程序。

worked for me in the shell scripte files.

在shell脚本文件中为我工作。

#11


0  

In tomcat/bin/catalina.sh

在tomcat / bin / catalina.sh

add the following line after just after the comment section ends:

在评论部分结束后添加以下行:

CATALINA_PID=someFile.txt

then, to kill a running instance of Tomcat, you can use:

然后,为了杀死Tomcat的运行实例,您可以使用:

kill -9 `cat someFile.txt`

#12


0  

kill -9 $(ps -ef | grep 8084 | awk 'NR==2{print $2}')

NR is for the number of records in the input file. awk can find or replaces text

NR是用于输入文件中的记录数。awk可以查找或替换文本。

#13


0  

To kill a process by name I use the following

我使用下面的名称来杀死一个进程。

ps aux | grep "search-term" | grep -v grep | tr -s " " | cut -d " " -f 2 | xargs kill -9

“搜索词”| grep -v grep -v grep | tr -s " | cut -d " - f2 | xargs kill -9。

The tr -s " " | cut -d " " -f 2 is same as awk '{print $2}'. tr supressess the tab spaces into single space and cut is provided with <SPACE> as the delimiter and the second column is requested. The second column in the ps aux output is the process id.

tr -s " " | cut -d " " - f2与awk '{print $2}相同。tr将标签空间插入到单个空格中,并以< space >作为分隔符,并请求第二列。辅助输出的第二列是进程id。