The Computer Oracle

How to kill all processes returned by pgrep

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Light Drops

--

Chapters
00:00 How To Kill All Processes Returned By Pgrep
00:20 Answer 1 Score 27
00:30 Accepted Answer Score 14
00:39 Answer 3 Score 1
01:13 Answer 4 Score 1
01:26 Thank you

--

Full question
https://superuser.com/questions/742715/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #ubuntu #process #kill

#avk47



ANSWER 1

Score 27


pkill python

Short and sweet, man pkill for details.




ACCEPTED ANSWER

Score 14


You can try:

pgrep python | xargs kill



ANSWER 3

Score 1


@tink has the correct answer, but I wanted to add that you want to make sure you are using the correct format for your machine. If you are using a Linux machine, pkill python is correct, but if you are using a Mac terminal, you will want to use pkill Python. So the most correct answer would be this:

pkill <process_name>

where <process_name> is the case-sensitive name of the process to kill.

Note: I understand that the tags for this question were related to Ubuntu Linux, but I wanted to clarify this for anyone that has a different machine but had this exact question (like myself).




ANSWER 4

Score 1


If pkill is a bit too radical for your tastes and you prefer to select which entries of the pgrep listing you want to kill, you can have a look at ezkill <https://github.com/Kraymer/ezkill> that i wrote.