#!/usr/bin/env python ‘‘‘ 处理访问日志,筛选时间大于1秒的请求 ‘‘‘ with open(‘test.log‘,‘a+‘,encoding=‘utf-8‘) as f_a: with open(‘wkxz-api.access.log‘) as f: for line in f.readlines(): if line[-2:] == "-\n" : num =float(line[-7:-2]) else: num=float(line[-6:]) if num >= 1.000 : f_a.write(line)
#!/bin/bash cat wkxz-api.access.log | while read LINE do #echo $LINE time=`echo $LINE| awk ‘{print $NF}‘ | awk ‘{print int($0)}‘` #echo $time if [ "$time" -ge "1" ];then echo $LINE >> wkxz-api.log fi done
原文地址:https://www.cnblogs.com/lrtao2010/p/9965900.html
时间: 2024-10-10 13:26:13