如何将进程名称从 supervisord 状态管道传输到 bash 中的另一个命令?
How to pipe process name from supervisord status to another command in bash?
在 supervisord
的帮助下,我在 Ubuntu 的后台有多个进程 运行
我想停止 supervisord
中的每个进程 运行,方法是使用以下命令并改编自解决方案 here
supervisorctl status | awk '{print }' | supervisorctl stop
我不知道如何获取 supervisorctl status
返回的进程名称(第一列)并将其传递给管道末尾的 supervisorctl stop
命令。
由于某些技术原因,我无法使用 supervisorctl stop all
。
如果有人可以建议如何使用 supervisorctl status
和管道方法停止所有进程,我们将不胜感激。
如果 supervisorctl stop
命令无法从标准输入中读取其参数,则应执行以下操作:
supervisorctl status | awk '{print }' | 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).
在 supervisord
我想停止 supervisord
中的每个进程 运行,方法是使用以下命令并改编自解决方案 here
supervisorctl status | awk '{print }' | supervisorctl stop
我不知道如何获取 supervisorctl status
返回的进程名称(第一列)并将其传递给管道末尾的 supervisorctl stop
命令。
由于某些技术原因,我无法使用 supervisorctl stop all
。
如果有人可以建议如何使用 supervisorctl status
和管道方法停止所有进程,我们将不胜感激。
如果 supervisorctl stop
命令无法从标准输入中读取其参数,则应执行以下操作:
supervisorctl status | awk '{print }' | 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).