Issue
I have multiple processes running in the background at Ubuntu with the help of supervisord
I want to stop each process running in supervisord
by using the command below & adapted from the solution here
supervisorctl status | awk '{print $1}' | supervisorctl stop $1
I do not know how to get the process name (1st column) returned by supervisorctl status
& pass it to supervisorctl stop
command at the end of the pipe.
I could not use supervisorctl stop all
due to some technical reasons.
So appreciate it if anyone could suggest how to stop all processes using supervisorctl status
& pipe method.
Solution
If the supervisorctl stop
command cannot read its parameter from the standard input the following should do what you want:
supervisorctl status | awk '{print $1}' | xargs supervisorctl stop
Explanation: xargs command
converts its standard input to arguments of command
and executes it.
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).
Answered By - Renaud Pacalet