Last active
August 29, 2015 14:22
-
-
Save becxer/624360138eed57d647f0 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
| #!/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