linux - 如何将进程名称从supervisord状态传递到bash中的另一个命令?

标签 linux bash ubuntu pipe supervisord

这个问题在这里已经有了答案:





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/

相关文章:

linux - 将数据作为文件提供给单独的进程而不写入磁盘?

linux - 确定哪些文件已更改或创建

linux - 管道 grep 进行切割

ubuntu - 将 DE 与 XMonad 配对

postgresql - PSQL:SSL 错误:未知协议(protocol)

linux - Ubuntu 17.10 上不存在 OpenJDK-9 JDK

c++ - 代码:: block linux glext.h "reference to uint64_t is ambiguous"

linux - 如何使用导出使 LLVM_SRC_ROOT 等于/llvm

接收到任何输入后运行 shell 脚本的 Linux 命令

linux - 修改 shell 脚本以返回与正确用户 ID 关联的名称