这个问题在这里已经有了答案:
How to pass command output as multiple arguments to another command
(5 个回答)
11 个月前关闭。
在 supervisord
的帮助下,我在 Ubuntu 后台运行了多个进程
我想停止 supervisord
中运行的每个进程通过使用以下命令并改编自解决方案 here
supervisorctl status | awk '{print $1}' | supervisorctl stop $1
我不知道如何获取 supervisorctl status
返回的进程名称(第一列)并将其传递给 supervisorctl stop
命令在管道的末端。我无法使用
supervisorctl stop all
由于一些技术原因。如果有人能建议如何使用
supervisorctl status
停止所有进程,将不胜感激。 &管法。
最佳答案
如果 supervisorctl stop
命令无法从标准输入中读取其参数,以下应该做你想要的:
supervisorctl status | awk '{print $1}' | xargs supervisorctl stop
解释:xargs command
将其标准输入转换为 command
的参数并执行它。Note:
xargs
has other benefits. It automatically splits the input in chunks of arguments such that the maximum total length of the command line is not exceeded. It can also parallelize several calls to its command (see the-P
option).
关于linux - 如何将进程名称从supervisord状态传递到bash中的另一个命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68653054/