最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
linux shell整理日志让awstats分析
时间:2014-05-08 编辑:简简单单 来源:一聚教程网
系统:centos 5.x
脚本内容:
代码如下 | 复制代码 |
#!/bin/bash file1=/var/log/nginx file2=/tmp/robeacc/log find=`find $file2 -name access.log|wc -l` if [[ $find = 1 ]];then rm -f $file2/* fi ls=`ls -1t $file1/w*.ro*.ac*.gz |head -1 ` cp -a $ls $file2/ gunzip $file2/* file3=`ls -1t $file2` mv $file2/$file3 $file2/access.log |
这里就不截图了,大家可以自己去测试下看看.这样一整是很方便的.
再给大家一个副产品:
代码如下 | 复制代码 |
#!/bin/bash file1=/root/log file2=/tmp/file if [ ! -d $file2 ];then mkdir $file2 fi rm -f $file2/* cp -a $file1/* $file2/ gunzip $file2/* for i in $file2/*;do ls --full-time $i |awk '{print $6}'|awk -F - '{print $1,$2,$3}' >>/root/1.txt;done sed 's/ //g' /root/1.txt>/root/t.txt rm -f 1.txt for i in `cat t.txt`;do mkdir /tmp/$i;done |
上面这个脚本可以根据日志的时间创建对应的文件夹,如图