我不明白为什么ps -al
或sudo ps -al
不会显示例如我的 java 进程。如果我这样做,ps -al
那么我看不到例如我的 java 作业,但是当我执行(奇怪且无法识别)时我可以看到它们,ps -xal | grep java
这可能应该是别的。我还可以通过 netstat 找到 java(jetty 服务器)正在运行的端口(端口 80)的 java PID,获取端口 80 上进程的 PID,然后通过其 PID 将其终止。我似乎并不总是sudo killall java
有效。您能否帮助我制定一个可行的策略,以简化处理 2-3 个 jetty 实例的运行,这些实例有时只会在执行时出现ps -al
?我想最好的方法是以类似于启动 ie 的方式停止 jetty,sudo mvn jetty:stop
但 jetty 手册说只需终止进程就可以了,这样更快。(我经常想重新启动 jetty。)
答案1
-a
和x
是进程选择器,因此ps
将显示过滤后的进程列表。如果要查看全部流程使用:
ps ax
,ps -ax
或ps -A
,甚至a
和-a
都不一样。参考:man ps
SIMPLE PROCESS SELECTION a Lift the BSD-style "only yourself" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes with a terminal (tty), or to list all processes when used together with the x option. -A Select all processes. Identical to -e. -a Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal. ... x Lift the BSD-style "must have a tty" restriction, which is imposed upon the set of all processes when some BSD-style (without "-") options are used or when the ps personality setting is BSD-like. The set of processes selected in this manner is in addition to the set of processes selected by other means. An alternate description is that this option causes ps to list all processes owned by you (same EUID as ps), or to list all processes when used together with the a option.
要杀死它,请尝试使用
sudo killall -s9 ...
。参考:终止命令和信号