Created
March 28, 2019 08:16
-
-
Save mmodrow/f49bdee4a85867a0dda960fc2642eb96 to your computer and use it in GitHub Desktop.
Killing processes by name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
processName=$1 | |
pids=$(ps -aux | grep $processName | egrep -v "grep|killingInTheNameOf" | awk '{ print $2 }') | |
names=$(ps -aux | grep $processName | egrep -v "grep|killingInTheNameOf" | awk '{ print $11 }') | |
#ps -aux | grep $processName | egrep -v "grep|killingInTheNameOf" | |
for name in $names; do echo $name; done | |
for pid in $pids; do echo $pid; sudo kill $pid; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment