Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to kill a few Python processes. I can get a list of the process numbers using pgrep python, but how can I kill them all at once instead of killing one by one?

I'm looking for something like:

pgrep python | kill process_nos
share|improve this question
man killall... – Alex P. Apr 16 '14 at 23:57
Besides possibly being a snide remark, "man killall" is not a correct answer. How would killall work with a Python script launched using "python /"? How about if that python cron were launched from a cron which first invokes a wrapper script? – Crossfit_and_Beer Mar 2 at 16:33
up vote 10 down vote accepted

You can try:

pgrep python | xargs kill
share|improve this answer
Why would you invoke THREE processes when one suffices? – tink Apr 17 '14 at 9:23
For one process it would be kill $(pgrep name) – Vadim Kirilchuk Feb 8 '15 at 17:56
pkill python

Short and sweet, man pkill for details.

share|improve this answer

@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).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .