Question: How to kill all processes matching a particular pattern in Linux?
Way #1
ps ax|grep [process_name_or_pattern]|awk ‘{print $1}’|xargs kill -9
What is it, tell me more?
ps ax | grep [process_name_or_pattern] – ps command piped through grep will list down all matching processes with PID in first column
awk ‘{print $1}’ – This’ll get you the value of first column i.e PID
xargs kill -9 – It’ll kill the process id printed by the above command
Way #2
pkill [process_name_or_pattern]
pkill will kill all processes matching the search text. If you’d like to know the process names that match the above command, use pgrep -l [process_name_or_pattern]
About this entry
You’re currently reading “Question: How to kill all processes matching a particular pattern in Linux?,” an entry on Singaram's Tech Musings
- Published:
- December 8, 2010 / 12:26 PM
- Category:
- Uncategorized
- Tags:

No comments yet
Jump to comment form | comment rss [?] | trackback uri [?]