标签:jdk 时间 path etc getc 24* open with open gets
# coding=utf-8 import os import time path = os.getcwd() index = 0 while True: # 当前时间戳 timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # java堆栈 jstack = os.popen(‘/mnt/jdk8/bin/jstack 30668‘).read() # 第一个堆栈文件 fp = path + ‘/jstack‘ + str(index) + ‘.log‘ # 将java堆栈写入文件 with open(fp, ‘a+‘) as f: f.write(timestamp + ‘\n‘ + jstack + ‘\n‘) # 判断存放堆栈文件大小以,大于100M后分包 fs = round(os.path.getsize(fp)/float(1024*1024), 2) if fs >= 100: index += 1 time.sleep(1)
标签:jdk 时间 path etc getc 24* open with open gets
原文地址:https://www.cnblogs.com/FengZiQ/p/13088235.html