OSX Terminal: how to kill all processes with the same name
5 answers
If you haven't pkill
, you can try this:
ps aux | grep python | grep -v grep | awk '{print $2}'
If this gives you the PIDs you want to kill then attach them to a kill command like this
kill $(ps aux | grep python | grep -v grep | awk '{print $2}')
That says ... kill all PIDs that are the result of the parenthesized command.
+14
source to share
@ shx2: Thanks for the trick! Here are the steps to get it working:
Step 1:
cd /usr/bin
Step 2:
touch "pkill"
Step 3. Using your chosen text editor, open the file you just created: / usr / bin / pkill (do this with sudo or your administrator). Copy / paste this and save:
for X in `ps acx | grep -i $1 | awk {'print $1'}`; do
kill $X;
done
Step 3. Set the file attribute
sudo chmod 755 /usr/bin/pkill
You are now ready to terminate any process with a simple syntax:
For example, to end all Python processes, open a shell and type:
pkill Python
All python processes should be removed.
+1
source to share