Skip to content

Instantly share code, notes, and snippets.

@becxer
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save becxer/624360138eed57d647f0 to your computer and use it in GitHub Desktop.

Select an option

Save becxer/624360138eed57d647f0 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#
# use to check process info logging
# @author becxer
# @email [email protected]
#
import os
import datetime
import time
import sys
if len(sys.argv) < 2 :
print "usage : proclog.py {proc-num}"
exit(1)
proc_id = sys.argv[1]
filename = proc_id+'_proclog.log'
outf = open('./'+filename,'a')
while True:
time.sleep(1)
ts = time.time()
st =datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
proc = open('/proc/'+proc_id+'/status','r')
pinfo = proc.read()
outf = open('./'+filename,'a')
outf.write(st)
outf.write(pinfo)
outf.close()
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment