Skip to content

Instantly share code, notes, and snippets.

@syndbg
Created July 23, 2014 14:52
Show Gist options
  • Save syndbg/f0ce1667728efe0f5ffa to your computer and use it in GitHub Desktop.
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
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