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]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: