Linux 如何在终端中终止这个 tomcat 进程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15236308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I kill this tomcat process in Terminal?
提问by Tom Maxwell
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
回答by Aurand
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 没有运行。您的搜索向您展示了搜索 tomcat 的 grep 进程。当然,当您看到该输出时,grep 不再运行,因此 pid 不再有效。
回答by Chris Knight
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 进程。
回答by Olaf Dietsche
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
.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 asgrep tomcat
.
将第一个搜索到的字符包装在字符类中
ps -ef | grep '[t]omcat'
这也搜索 tomcat,但错过了
grep [t]omcat
条目,因为它与[t]omcat
.使用带有 ps 的自定义输出格式
ps -e -o pid,comm | grep tomcat
这仅显示进程的 pid 和名称,而没有进程参数。因此,grep 被列为
grep
而不是列为grep tomcat
。
回答by ASR
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
回答by suryakrupa
ps -ef | grep tomcat | awk '{print $2}' | xargs kill -9
ps -ef | 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
ps -ef | 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
awk '{print $2}' | xargs kill -9 => 获取第二列 [Process id] 并使用 -9 选项杀死它们
Hope this helps.
希望这可以帮助。
回答by Darshan
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
回答by dobrivoje
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 }' | xargs kill -9
回答by jaydip jadhav
This worked for me:
这对我有用:
Step 1 : echo ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $2 }'
第 1 步:回声 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
Step 2: kill -9 process_id
// 这个process_id和Step 1一样:输出
回答by ccjeaty
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.
ps -ef |grep java | grep tomcat
命令忽略ps
程序。
worked for me in the shell scripte files.
在 shell scripte 文件中为我工作。
回答by Vaibhav
ps -Af | grep "tomcat" | grep -v grep | awk '{print}' | xargs kill -9