Skip to content

Instantly share code, notes, and snippets.

@prehensilecode
Created February 25, 2014 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prehensilecode/9212787 to your computer and use it in GitHub Desktop.
Save prehensilecode/9212787 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import os
import re
import shlex
import subprocess as sp
def main():
lines = sp.Popen(['ps', '-elf'], stdout=sp.PIPE).communicate()[0]
vasp_pat = re.compile(r'VASP')
for l in lines.splitlines():
vp = vasp_pat.search(l)
if vp and l.split()[4] == '1':
pid = l.split()[3]
sp.Popen(['kill', pid])
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment