Skip to content

awstats 如何统计以前的日志?


作者:wd 发表于:2007-04-02 17:33 最后更新于:2007-04-02 17:34
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处[http://wdicc.com/awstats-log/]和作者信息及本版权声明。

突然想安装一个awstats了,参考 车东 的文章,安装了一个。可是发现一个问题,设置了logfile为 access_log.%YYYY-24%MM-24%DD-24.log 之后,发现只能把昨天的日志统计进来,可是我的log下面还有好多呢,想统计以前的,怎么弄呢?幸好,awstats已经考虑到这个问题了。

awstats.pl 脚本支持在命令行指定logfile,这样简单了,改变这个参数就可以了。不过要注意的是,如果你的data里面已经处理新的日志,那么指定logfile也没用了,以前的没办法更新进来了。只能是删掉data里面的内容,然后重新从最早的开始生成一遍。我写了一个脚本来做这个事情。

#!/bin/bash
 
awstats_dir=/opt/tt2/awstats/wwwroot/cgi-bin
logfile_dir="/usr/local/apache/logs/"
 
cd $awstats_dir
 
for file in `find $logfile_dir -name "access_log.2*" | sort`;do
        #echo "$file"
        ./awstats.pl -update -config=wd -LogFile=$file
done

保存为 awstats.sh ,然后执行就可以了。他会查找 logfile_dir 下面所有的 access_log.2 开头的文件,作为参数来更新记录。

One Trackback/Pingback

  1. [...] http://blog.wdicc.com/wordpress/2007/04/02/316/ 介绍了awstats 如何统计以前的日志 [...]

Post a Comment

Your email is never published nor shared.

For spam filtering purposes, please copy the number 5411 to the field below: