问题标签 [ps]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
234 浏览

perl - 本地化 $0 后显示原始参数

使用 arguments 运行时a b c d e f g,此脚本:

打印类似:

也就是说,在第三种情况下ps不显示原始的 argv 数组。

a b c d e f g有没有办法可以通过恢复/显示原始参数(例如) ps

我正在使用 Centos 和 Ubuntu。

0 投票
7 回答
145213 浏览

macos - 如何检查 OS X 终端中的进程?

我想查看在 OS X 中运行的进程的信息。ps在终端中运行只列出打开的终端窗口。如何查看所有正在运行的进程?

假设我正在运行 Web 浏览器、终端和文本编辑器。我想查看文本编辑器和网络浏览器的信息。

0 投票
1 回答
12198 浏览

unix - ps按开始时间排序结果

ps我正在使用各种命令显示有关当前进程的信息:

如何按开始对这些结果进行排序?

我已经阅读man ps并尝试过-m-r以及-v排序选项。不幸的是,我无法使用这些选项按开始排序。

0 投票
2 回答
5419 浏览

linux - 调试 postgreSQL 服务器进程(如何识别正确的进程 id)

我使用 V1 调用约定为 PG 编写了一个 C 扩展库。我的数据库是 8.4 版。我已经成功创建了新功能。

但是,当我调用我的新函数时,它会使服务器崩溃,并将以下消息发送到控制台:

服务器日志包含以下行:

我想将 gdb 附加到 postgres 进程,看看是否可以获得堆栈跟踪,以帮助我开始调试。但是,当我跑步时

ps辅助| grep postgres

为了尝试定位 postgres 进程,似乎有几个名为 postgres 的进程。

如上所述,出于调试目的,我如何正确识别 postgres 服务器进程(重新启动后)?

0 投票
1 回答
222 浏览

ubuntu - Debian 32 与 Ubuntu 64 上的 PHP CLI 进程标题非常不同

我有两台服务器Debian Squeeze 32Ubuntu 11.10 Server 64。具有相同命令的相同脚本的行为非常不同。

脚本 test.php:

命令:

Debain:我看到正在打印的数字和流程标题php -q test.php符合预期。pidof "php -q test.php"工作正常。

Ubuntu:没有数字;进程标题是php. pidof "php -q test.php"不起作用,我不能使用pidof php.

Ubuntu有什么问题?

更新哇!pgrep -f "php -q test.php"效果很好,pidof "php -q test.php"但不行。

更新 2我不确定这是否适用,但在 Debian 下,我在常规控制台中工作,而 Ubuntu 正在通过 SSH 访问。

0 投票
1 回答
324 浏览

bash - ps和tty中不同的终端id

我开始的进程与 tty 结果的终端 ID 不同。有什么规则吗?如果我启动它们,有没有办法找出程序会有什么终端 ID?

我通过 putty 连接到 openSUSE 11.3 机器。

0 投票
4 回答
4473 浏览

linux - 使用“ps”查找时间范围内的进程

我怎样才能找到最近 5 小时内开始处理的?能ps做到吗?

我必须使用ps -ef | grep <username>which 显示所有进程。然后我必须手动查看 STIME 列

0 投票
2 回答
847 浏览

haskell - 在 Haskell 中设置 argv[0]?

有没有办法argv[0]在 Haskell 程序中设置(比如说,用 ghc 编译的程序)?

我在 System.Environment 中找到了getProgNameandwithProgName函数,但它似乎并没有改变ps报告的内容(Ubuntu)。

0 投票
1 回答
3309 浏览

bash - 在 bash 脚本中使用 ps 时如何获取当前时间戳?

所以我正在编写一个 shell 脚本来运行所有当前进程,并将它们通过管道传递到 grep 以过滤掉我需要的那些。

但是我也需要它给我一个时间戳无论是在PS发生时,还是在进程启动时,都无所谓,我只需要一个时间。所有的过程只需要几分之一秒。

我的命令是这样的:

我试过这样:

但这只是给了我一个像 hh:mm:ss 这样的时间。我需要比这更精确的东西。时间戳是理想的。

有任何想法吗?

0 投票
1 回答
1199 浏览

sleep - Process under FreeBSD 9.0 hangs in uninterruptable sleep with apparently no syscall (empty wchan)

I have a custom logging process that is reading from STDIN and sending the data out via TCP to a scribed logging server. STDIN is in my case an access log that is attached to Apache httpd 2.2 like this in httpd.conf: CustomLog "|/usr/local/bin/serelog" default

My serelog process sometimes goes into uninterruptable sleep under FreeBSD 9.0 and does not return from it. It works reliably under other operating systems though, including FreeBSD 8, Linux 2.6 and Linux 3.1.

How can I find out what could be the reason for the uninterruptable sleep?

The overall structure is like this: httpd --[PIPE]--> serelog --[TCP-CONNECTION]--> scribed

Until now I did the following analysis:

  • Using ps: stat is "D" and wchan is "-". So there is apparently no syscall, which doesn't make too much sense to me, as the process in uninterruptable sleep and should be in kernel land.
  • As the process is in state "D", the process does not react to kill -9 as expected.
  • Attaching truss to serelog externally from a shell: As long as truss is attached, serelog runs smoothly. Shortly (Seconds) after detaching truss from serelog, serelog goes into "D" state.
  • When attaching truss to serelog AFTER it has entered "D" state, truss prints nothing
  • In "D" state, lsof shows that the incoming PIPE is full. This is exected, as in "D" state the process "sleeps" and cannot read any longer. The outgoing TCP-CONNECTION is empty.
  • If I kill the "surrounding" Apache httpd server, the serelog process eventually terminates after (e.g.) 40 minutes.
  • Checking what others report in forums about the uninterruptable problem was not successful: In my setup there is no NFS. And as it is a server there is also no user interaction with CD drives or pluggable hardware.

So I am now stuck with a process that is uninterruptable, is apparently not in a syscall, and works reliably when traced. The only good thing is that I am able to reproduce the behavior in a few seconds or minutes when I send a lot of HTTP requests via JMeter loadtest (5 threads in JMeter).

Any tips on debugging, kernel parameter tuning are appreciated.

Greetings