You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
524 B
28 lines
524 B
#!/usr/bin/python
|
|
|
|
import os,sys
|
|
import time,datetime
|
|
|
|
LOG_FILE = "./brathuhn.log"
|
|
ROT_SIZE = 2**20
|
|
ROT_CRITICAL = 2**20+50*2**10
|
|
|
|
f = open(LOG_FILE,'wb')
|
|
|
|
cnt = 0
|
|
|
|
c = sys.stdin.read(1)
|
|
while c!='':
|
|
f.write(c)
|
|
cnt+=1
|
|
if c=='\n' and cnt>=ROT_SIZE or cnt>=ROT_CRITICAL:
|
|
f.close()
|
|
os.rename(LOG_FILE, LOG_FILE+date.strftime("_%Y-%m-%d_%H-%M-%S") )
|
|
f = open(LOG_FILE,'wb')
|
|
|
|
date=datetime.datetime.fromtimestamp(time.time())
|
|
print "rotate",cnt,date.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
cnt = 0
|
|
c = sys.stdin.read(1)
|
|
|
|
|