Created
June 25, 2015 15:33
-
-
Save shoaibi/18749d60600fd72af798 to your computer and use it in GitHub Desktop.
Kill a process by its (partial) name
This file contains 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 | |
E_BADARGS=65 | |
if [ $# -ne 2 -a $# -ne 1 ] | |
then | |
echo "Usage: $0 {processNameWithoutSpaces} [{signal}]" | |
exit $E_BADARGS | |
fi | |
process_name="$1" | |
signal="$2" | |
if [ "x$signal" = "x" ]; then | |
signal="-9" | |
fi | |
sudo ps aux | grep "$process_name" | grep -v "grep $process_name" | awk '{print $2}' | xargs sudo kill "$signal" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment