Я действительно предпочитаю использовать команду pgrep / pkill. Вот пример:
[root@testrhel7 ~]# pgrep -l http
2967 httpd
2968 httpd
2969 httpd
2970 httpd
2971 httpd
2972 httpd
[root@testrhel7 ~]#
[root@testrhel7 ~]# pkill -e http
httpd killed (pid 2967)
httpd killed (pid 2968)
httpd killed (pid 2969)
httpd killed (pid 2970)
httpd killed (pid 2971)
httpd killed (pid 2972)
[root@testrhel7 ~]#
Конечно, вы можете использовать цикл for:
[root@testrhel7 ~]# ps -ef |grep http| grep -v grep
root 2989 1 0 16:06 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2990 2989 0 16:06 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2991 2989 0 16:06 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2992 2989 0 16:06 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2993 2989 0 16:06 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2994 2989 0 16:06 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
[root@testrhel7 ~]#
[root@testrhel7 ~]# for i in $(ps -ef | awk '/http/ {print $2}'); do kill -9 $i; done
Я надеюсь это было полезным, счастливым убийством.