Created
July 23, 2014 14:52
-
-
Save syndbg/f0ce1667728efe0f5ffa to your computer and use it in GitHub Desktop.
Python script that runs **jps** and kills non-jps and eclipse processes. Useful for when your JVM gets fat with processes
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
import subprocess | |
def main(): | |
jps_processes = subprocess.check_output(["jps"]).split("\n") | |
for line in jps_processes: | |
if not "jps" in line.lower() and not "eclipse" in line.lower(): | |
line = line.split() | |
try: | |
process_id = line[0] | |
except IndexError: | |
return | |
subprocess.call("kill -9 %s" % process_id, shell=True) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment