Killing processes SHELL
The normal way to do this is to use xargs
as in ps -ef | grep php | xargs kill
, but there are several ways to do this.
ps -ef
lists all processes and then you usegrep
to pick a few lines that mention "php". This means that also commands that have "php" as part of their command line will match, and be killed. If you really want to match the command (and not the arguments as well), it is probably better to usepgrep php
.You can use a shell backtick to provide the output of a command as arguments to another command, as in
kill `pgrep php`
If you want to kill processes only, there is a command
pkill
that matches a pattern to the command. This can not be used if you want to do something else with the processes though. This means that if you want to kill all processes where the command contain "php", you can do this usingpkill php
.
Hope this helps.