goaccess生成nginx每日访问纪录

时间:2014-05-09 02:56:20   收藏:0   阅读:371

使用php写的,方便点

bubuko.com,布布扣
<?php
    // 定义全局参数
    $date = date("Ymd");
    $day = date("d", strtotime(‘-1 day‘));
    $month = date("M");
    $year = date("Y");
    
    $LOG = "nginx_{$date}.log";
    $HTML = "nginx_{$date}.html";
    
    // 先生成当天的nginx日志文件
    $cmd = "sed -n ‘/{$day}\/{$month}\/{$year}/ p‘ /var/log/nginx/log/host.access.log > $LOG";
    `$cmd`;
    _debug($cmd);
    // 再使用goaccess生成网页
    $cmd = "/usr/local/bin/goaccess -f $LOG -a > /yfdata/mobile/$HTML";
    `$cmd`;
    _debug($cmd);
    _debug("success");
    
    function _debug($msg) {
        echo "$msg\n";
    }
?>
bubuko.com,布布扣

 

 

goaccess生成nginx每日访问纪录,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!