问题标签 [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 投票
4 回答
7350 浏览

awk - 使用 awk 从“ps aux”输出中获取内存使用情况

我必须使用 awk 解决一个练习。基本上我需要从“ps aux”命令中检索每个用户的内存使用总量和格式,如下所示:

等等。

我似乎无法解决的问题是:我怎么知道有多少用户登录?我怎样才能为他们中的每一个做出不同的总和?

谢谢 :)

0 投票
4 回答
474 浏览

command - ubuntu 服务器 PS,ifocnfig,命令不起作用

我过去几个月一直在 ubuntu 服务器上工作,现在突然 ps,ifconfing commnad 停止工作并出现以下错误。

user1@Fb1:/usr/bin$ ps -bash: /bin/ps: 没有那个文件或目录

让这个命令恢复正常的任何建议。

0 投票
3 回答
11052 浏览

linux - 从 Linux 'ps' 生成 CSV 列表

假设我有一个ps如下所示的命令:

它会给我一个“空格”分隔的行集。一行可能看起来像这样

我想说服 ps 用逗号(甚至制表符!)分隔,这样它就可以被其他语言自动处理。请注意, args 中可能会有空格,因此,按字段唤醒本身不会起作用。

0 投票
8 回答
20840 浏览

bash - 如何在bash中更改argv0,以便命令在ps中显示不同的名称?

在 C 程序中,我可以编写 argv[0] 并且新名称显示在 ps 列表中。

我怎样才能在 bash 中做到这一点?

0 投票
4 回答
6714 浏览

python - 有没有办法以编程方式获取 ps 输出?

我有一个网络服务器,我目前正在对 CPU 使用率进行基准测试。我所做的实际上是运行一个进程来向服务器发送请求,然后运行以下 bash 脚本来确定 CPU 使用率:

能够在 Python 中执行此操作会很好,因此我可以在一个脚本中运行它,而不必运行两个。我似乎找不到任何独立于平台(或至少独立于 linux 和 OS X 的平台)的方式来获取 Python 中的 ps 输出,而无需实际启动另一个进程来运行该命令。我可以做到这一点,但如果有一个 API 可以做到这一点,那就太好了

有没有办法做到这一点,或者我将不得不启动外部脚本?

0 投票
1 回答
597 浏览

c - 如何在 C 程序中设置命令行参数,使其在用户键入“ps aux”时可见?

当您键入“ps aux”时,ps 命令会显示程序运行时使用的命令参数。一些程序将其更改为指示状态的一种方式。我尝试更改 argv[] 字段,但似乎不起作用。有没有一种标准的方法来设置命令行参数,以便它们在用户键入 ps 时出现?

也就是说,这不起作用:

0 投票
4 回答
4702 浏览

regex - Regex process using cut(Linux)(sh)

I'm having a problem with regex in using the command sh cute, the problem is that I want to show all processes that start with g and just show the command, but do not know, help me please?

To do this I use the command:

but this show all process who contains the letter g and i need who start with g and cut the command to get this, for example i get a output of ps

1000 4571 0.0 0.0 12724 868 pts/4 S+ 19:21 0:00 grep --color=auto g

And I need get only /sbin/getty because is in path and the command grep. In definite get all files start with g and cut and cut above so that it is the command and attributes PD: I need use to get all with the commands grep and cut, and i can't don't use the pgrep.

Thanks in advance

0 投票
2 回答
3192 浏览

linux - 如何在linux中获取进程的进程树跟踪/日志?

我想知道脚本启动了哪些可执行文件以及以什么顺序启动(并递归地跟踪这些可执行文件)。

例如,假设我在这里有一个 bash 脚本(称为 abc.sh):

我想用“trace/log command”运行这个脚本并得到这样的东西:

这表明 abc.sh 调用了 ls 和 gcc。gcc 反过来又称为 cpp 和 cc1。

这可能吗?我该怎么做?像上面这样的树视图会很好,但更简单的视图也可以。

请注意,我不想要进程树的当前快照。相反,我想要生成过程的跟踪或日志。时间注释也很有用。

谢谢!

0 投票
4 回答
7505 浏览

linux - 多个同名进程

我有一个在 Linux 2.6.13 和 WindRiver Linux 3.0 上运行的应用程序。在 Linux 2.6.13 中,当我...

...输出显示“myapplication”的多个条目。

如果我在 WindRiver Linux 3.0 中给出相同的命令,输出只显示一个“myapplication”条目

差异与所使用的操作系统的差异有关吗?请告诉我这是什么原因?

0 投票
3 回答
4559 浏览

linux - linux : 寻找 postgres 空闲进程的发起者

实际上,我正在运行四个守护程序。它建立了 postgres 连接,并与这些东西断开了一次连接。但是当我放置 ps aux 时,我的系统中有很多 postgres 空闲进程正在运行。我只想知道,每个空闲 postres 进程的发起者。所以,我可以找出哪个进程没有正确关闭 postgres 连接。

提前致谢 。