【问题标题】:How to find the main process PID without `master` identification?如何找到没有`master`标识的主进程PID?
【发布时间】:2021-07-30 23:49:58
【问题描述】:

没有master标识如何找到主进程PID?

在这种情况下:

[root@4d62e42f3cde conf.d]# ps -ef | grep demosoft
root      1700     1  0 08:34 pts/0    00:00:00 grep --color=auto demosoft
root     26814     1  0 Apr12 ?        00:00:00 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26815 26814  0 Apr12 ?        00:01:33 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26816 26814  0 Apr12 ?        00:01:36 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26817 26814  0 Apr12 ?        00:01:35 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26818 26814  0 Apr12 ?        00:01:32 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26819 26814  0 Apr12 ?        00:01:30 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26820 26814  0 Apr12 ?        00:01:29 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26821 26814  0 Apr12 ?        00:01:29 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26822 26814  0 Apr12 ?        00:01:30 demosoft --config=/etc/demosoft/demosoft.conf
demosoft    26823 26814  0 Apr12 ?        00:01:44 demosoft --config=/etc/demosoft/demosoft.conf

我只知道使用命令: ps -ef | grep demosoft | awk '{print $2}' 获取 PID:

1710
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823

我想向主进程发送 SIGHUP 信号。但是怎么做?

你知道如果它是一个 Nginx 进程,我可以通过以下方式发送 SIGHUP 信号:

kill -HUP $(ps -ef | grep nginx | grep master | awk '{print $2}')

但是demosoft没有master标识。

【问题讨论】:

  • 缺少解释。您能否通过editing 在您的问题中添加一百字的书面英语来解释什么是“主标识”?

标签: linux process signals


【解决方案1】:

您可以在阅读其文档后安装然后使用pstree(1) 命令。

您还可以在阅读了它们的文档后使用top(1)pgrep(1)pkill(1) 命令。

在阅读了更多文档和Advanced Linux Programming

在大多数 Linux 系统上,您可以访问 /proc/ - 请仔细阅读 proc(5)

您可能想阅读与systemd(1)credentials(7) 相关的文档。

我还建议阅读Nginx 的文档。由于它是开源软件,您可以download its source code然后改进它。

您甚至可以(但这样做存在网络安全风险)通过 Web 界面向远程 kill(2) 进程(或使用 killpg(2))编写一些 FastCGI 事物,或使用 libonion 编写一些 Web 服务这样做,或者(在 2021 年春季或夏季)为RefPerSys 项目做出贡献以更聪明地这样做

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-26
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    • 2015-10-05
    • 1970-01-01
    相关资源
    最近更新 更多