Skip to content

Instantly share code, notes, and snippets.

@mmodrow
Created March 28, 2019 08:16
Show Gist options
  • Save mmodrow/f49bdee4a85867a0dda960fc2642eb96 to your computer and use it in GitHub Desktop.
Save mmodrow/f49bdee4a85867a0dda960fc2642eb96 to your computer and use it in GitHub Desktop.
Killing processes by name
#!/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