标签: pgrep

这么多Apache实例正常吗?

我们2.2.8-1ubuntu0.15在我们的 VPS 实例上运行 Apache 版本Ubuntu 8.04.4 LTS \n \l,正如我通过问这个问题确定的那样。

当我发出时pgrep apache2,我得到以下信息:

 2691
24517
25330
25669
25672
25795
25796
25809
25825
26401
26402
Run Code Online (Sandbox Code Playgroud)

这是 11 个单独的实例apache2!这是正常的吗?如果没有,我该怎么办?

ubuntu-8.04 multiple-instances pgrep apache-2.2

5
推荐指数
1
解决办法
3825
查看次数

pgrep 搜索多个单词

我用来pgrep查找正在运行的进程有一些单词

> pgrep -f "otp"
2345
2343
Run Code Online (Sandbox Code Playgroud)

识别了多个进程。命令行中还有另一个单词可以帮助我将确切的过程归零。所以,我想搜索两个术语,并且两个术语都应该在那里。不幸的是,我只看到 OR 组合的示例和帮助,如下所示:

> pgrep -f "otp|place1"
2345
2343
3632
Run Code Online (Sandbox Code Playgroud)

这是行不通的,因为它是一个 OR 条件。我的搜索模式中需要一个 AND 条件。

pgrep 参考: https: //linux.die.net/man/1/pgrep

模式:指定用于匹配进程名称或命令行的扩展正则表达式。

如何使用 pgrep 搜索 AND 组合而不是 OR 的两个单词?

linux pgrep

5
推荐指数
1
解决办法
5211
查看次数

当通过其他命令进行管道传输时,pgrep 返回额外的进程

这是一个非常奇怪的问题,关于使用 pgrep 搜索哪些 shell 进程正在运行与当前进程相同的脚本。

\n

这是名为test.sh的测试脚本

\n
#!/bin/bash\n\nfull_res=`pgrep -a -l -f \'test\\.sh\'`\n\nres=$(pgrep -a -l -f \'test\\.sh\' | cat)\n\necho "short result is $full_res"\n\necho "weird result is $res"\n
Run Code Online (Sandbox Code Playgroud)\n

输出为

\n
sh test.sh &\n[1] 19992\n\xe2\x9e\x9c  logs short result is 19992 sh test.sh\nweird result is 19992 sh test.sh\n19996 sh test.sh\n\n[1]  + 19992 done       sh test.sh\n
Run Code Online (Sandbox Code Playgroud)\n

我不知道这些声音从何19996 sh test.sh而来,尤其是在使用管道猫时。我相信这可能是 pgrep 实现的一个错误。

\n

期待合理的解释

\n

谢谢,

\n

巴林

\n

linux shell pgrep

5
推荐指数
2
解决办法
866
查看次数

pgrep wget:进程ID的详细信息是什么?

打字时pgrep wget,它显示进程ID10144

但是如何知道这个进程ID的细节是什么

wget pgrep

3
推荐指数
1
解决办法
574
查看次数

puppet onlyif with pgrep 不起作用

只有当它的进程没有运行时,我才想在 puppet 中使用 exec

exec { "execute me":
    onlyif  => "pgrep -fc 'ruby execute.rb'",  
    command => "execute me",
}
Run Code Online (Sandbox Code Playgroud)

因此,在上述情况下,如果进程 'ruby execute.rb' 已经在运行,则 exec 不应作为

pgrep -fc 'ruby execute.rb' will return 1.
Run Code Online (Sandbox Code Playgroud)

然而

该命令似乎总是在 puppet 中运行。

在我的 linux 机器上,当我执行 pgrep -fc 'ruby execute.rb' 时,我总是得到大于 0 的值。

我的命令有问题吗?

linux puppet pgrep

3
推荐指数
1
解决办法
2067
查看次数