Last active
August 29, 2015 14:12
-
-
Save nkigen/e3a9c8483c579be44ba2 to your computer and use it in GitHub Desktop.
Kill processes that usually run in the background even after exiting (This script was initially targeted at the notorious viber :-) )
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 | |
#Kill processes that don't usually run in the background even after exiting | |
# (This script was initially targeted at the notorious viber :-) ) | |
#nelson kigen<[email protected]> | |
SUDO_ACCESS="" #Optionally put your sudo pwd here | |
no_param(){ | |
case "$1" in | |
"") | |
echo $2 && return 1;; | |
esac | |
} | |
kill_target(){ | |
no_param $APP_NAME "No kill target supplied" | |
_PID=$(ps -ax | grep ${APP_NAME} | awk -F" " '{print $1}') | |
no_param $APP_NAME "" | |
case "$SUDO_ACCESS" in | |
"") | |
sudo kill -9 $_PID && return 1 | |
esac | |
echo ${SUDO_ACCESS} | sudo -S kill -9 _PID | |
} | |
main(){ | |
export APP_NAME='$1' | |
kill_target | |
} | |
main $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment