Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill all processes with a given partial name? [closed]

Tags:

linux

bash

posix

I want to kill all processes that I get by:

ps aux | grep my_pattern 

How to do it?

This does not work:

pkill my_pattern 
like image 504
Łukasz Lew Avatar asked Jan 24 '12 12:01

Łukasz Lew


People also ask

How do I kill all processes in a specific name?

Kill process by name with killall and pkill First, killall accepts a process name as an argument rather than PID. And the other difference is that killall will, as the name implies, kill all instances of a named process. Contrast this to the regular kill command which only ends the processes you explicitly specify.

How do I kill multiple processes with the same name?

killall Command – kill the processes by name. By default, it will send a TERM signal. The killall command can kill multiple processes with a single command. If more than one process runs with that name, all of them will be killed.

Which command can be used to kill processes by name rather than process ID?

There are two commands used to kill a process: kill – Kill a process by ID. killall – Kill a process by name.


1 Answers

Use pkill -f, which matches the pattern for any part of the command line

pkill -f my_pattern 

Just in case it doesn't work, try to use this one as well:

pkill -9 -f my_pattern 
like image 178
Dor Shemer Avatar answered Nov 07 '22 07:11

Dor Shemer