Created
January 3, 2013 08:57
-
-
Save rantav/4441958 to your computer and use it in GitHub Desktop.
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
def kill_by_name(name): | |
"Kills a process by name (or any unique string). The name is a string from the command line (so be caraful of multiple occurrences)" | |
cmd = "ps aux | grep '%s' | grep java | grep -v grep | awk '{print $2}' | xargs kill" % name | |
with settings(hide('stdout'), warn_only=True): | |
sudo(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In some more modern linux installs, may want to try pkill or pkill -f for a simpler way of accomplishing this