楼主之前一直用shell进行日志分析,但是日志过大,导致分析起来非常慢,楼主的思想是,把日志切割成n份,利用python多线程去分析岂不是快n多倍
#!/usr/bin/python
file=open("/home/test","r")
list=[]
fenge=""
def hanShu1():
for i in file:
list.append(i)
hanShu1()
changdu=len(list)
jisuan=changdu/2
print jisuan
d=range(0,jisuan)
print d
def lieBiao():
sum=0
g=0
for c in d:
if sum == 0:
sum=sum+jisuan
print sum
a=list[0:sum]
print a
k="".join(a)
print k
lujing="/home/python/rizhi/"+str(sum)
print lujing
aa=open(lujing,"w+")
bb=str(k)
aa.write(k)
aa.read()
elif sum > 0:
g+=g
print g
f=sum
sum+=jisuan
print sum
g=list[f:sum]
print g
j="".join(g)
print j
lujing1="/home/python/rizhi/"+str(sum)
print lujing1
cc=open(lujing1,"w+")
dd=str(j)
cc.write(dd)
lieBiao()
if sum != changdu:
shengyu=changdu-sum
print shengyu
shengyu1=list[shengyu:changdu]
cc=open("/home/python/rizhi/zuizhong","w+")
cc.write(shengyu1)