Skip to content

Instantly share code, notes, and snippets.

@nkigen
Last active August 29, 2015 14:12
Show Gist options
  • Save nkigen/e3a9c8483c579be44ba2 to your computer and use it in GitHub Desktop.
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 :-) )
#!/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<nellyk89@gmail.com>
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