How to kill all processes with a given partial name?
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
How to kill all processes matching a name?
From man 1 pkill
-f The pattern is normally only matched against the process name.
When -f is set, the full command line is used.
Which means, for example, if we see these lines in ps aux
:
apache 24268 0.0 2.6 388152 27116 ? S Jun13 0:10 /usr/sbin/httpd
apache 24272 0.0 2.6 387944 27104 ? S Jun13 0:09 /usr/sbin/httpd
apache 24319 0.0 2.6 387884 27316 ? S Jun15 0:04 /usr/sbin/httpd
We can kill them all using the pkill -f
option:
pkill -f httpd
How can I kill a process by name instead of PID, on Linux?
pkill firefox
More information: http://linux.about.com/library/cmd/blcmdl1_pkill.htm
Kill all processes by command
Try this
ps aux | grep 'ssh-agent -s' | awk '{print $2'} | xargs kill -9
How to kill all processes with the same name using OS X Terminal
use pkill, with the -f
option.
pkill -f python
If you don't have pkill
pre-installed (some osx's don't...), try proctools.
Kill all processes by command
Try this
ps aux | grep 'ssh-agent -s' | awk '{print $2'} | xargs kill -9
Related Topics
How to Split One Text File into Multiple *.Txt Files
How to Redirect Output of Systemd Service to a File
Forward Host Port to Docker Container
How to Get Cmake to Find My Alternative Boost Installation
Bluetooth Low Energy: Listening For Notifications/Indications in Linux
How to Loop Over the Output of a Shell Command
How to Create Docker Overlay Network Between Multi Hosts
Bash Script Process Substitution Syntax Error: "(" Unexpected
The Difference Between Fork(), Vfork(), Exec() and Clone()
Redirect Stderr/Stdout of a Process After It's Been Started, Using Command Line
Linux: Copy and Create Destination Dir If It Does Not Exist
How to Redirect the Output of the Time Command to a File in Linux
Use of Floating Point in the Linux Kernel
How to Setup Public-Key Authentication
Setting Environment Variables in Linux Using Bash
Run an Ansible Task Only When the Variable Contains a Specific String
Printing an Integer as a String With At&T Syntax, With Linux System Calls Instead of Printf