我正在尝试通过这个shell脚本中的ID杀死一个进程。
# based on
# http://stackoverflow.com/questions/6437602/shell-script-to-get-the-process-id-on-linux
output=`ps -ax|grep Ad[o]be\ After\ Effects\ CS6`;
# set -- parses the ps output into words,
# and $1 is the first word on the line
# which happens to be the process ID
set
我在Ubuntu上运行Rails,使用的是Nginx web服务器和5个瘦应用服务器。
每天一次,系统变得非常慢,有时会挂断。
我不确定是否是瘦服务器,但当我在挂起时停止服务器时,我会得到:
Can't stop process, no PID found in tmp/pids/thin.3000.pid
以下是显示精简启动和停止的日志:
bitnami@linux:/opt/bitnami$ thin -C projects/myapp/current/config/thin.yml start
Starting server on 127.0.0.1:3000 ...
Start
我需要在linux上的bash中找到某个java进程的pid。
如果只有一个java进程,
PID=$(pgrep java)
很管用。
对于多个java进程,它变得更加复杂。我手动运行pstree,找到我首先需要的java进程的祖先,然后找到问题中的java进程。在bash中可以这样做吗?基本上,我需要在伪代码中显示的功能:
Having `processname1` and `processname2`
and knowing that `processname2` is in the subtree of 'processname1',
find the pid of `
我需要获取通过Java的Runtime.getRuntime().exec()命令启动的进程的PID。
我知道如何在JNA中这样做。但我真的想用JNI来做这件事,并创建我自己的库。有人知道怎么做吗?
import java.lang.reflect.Field;
class GetPid
{
public native int getPid( long procHandle);
static
{
System.loadLibrary("getpid");
}
public static void main(Strin
我使用的是Ubuntu Linux 11.04。我需要定期清理类似以下内容的孤立Flash进程
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
0 R selenium 25949 1 54 80 0 - 19187 - 00:09 ? 05:26:03 /usr/lib/nspluginwrapper/i386/linux/npviewer.bin --plugin /usr/lib/flashplug
我知道它们是孤立的,因为父pid (PPI
从阅读文档和在线上看,大多数人都说要在linux中杀死一个进程,只需要命令kill "pid“。
For example to kill memcached would be kill $(cat memcached.pid)
但对于我试图杀死的几乎每个进程,包括上面的进程,这都是不起作用的。我设法用一个不同的命令让它工作:
ps aux | grep (process name here)
无论出于什么原因,该命令都会得到一个不同的pid,这将在终止程序时起作用。
我想我的问题是,为什么会有不同的pid?id的意义不是唯一的吗?为什么在使用aux | grep命令时,celery、m
$ netstat -nap
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
Active UNIX domain sockets (servers and established)