cxs7225032 发表于 2018-11-16 09:33:20

awstats 统计 nginx日志切割

  1、nginx
  cut_nginx_logs.sh
  (在lnmp一键安装中有这个脚本,直接拿来用就行了)
  #!/bin/bash
  #function:cut nginx log files for lnmp v0.5 and v0.6
  #author: http://lnmp.org
  #set the path to nginx log files
  log_files_path="/var/www/wwwlogs/"
  log_files_dir=${log_files_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")
  #set nginx log files you want to cut
  log_files_name=(access)
  #set the path to nginx.
  nginx_sbin="/usr/local/nginx/sbin/nginx"
  #Set how long you want to save
  #save_days=30
  ############################################
  #Please do not modify the following script #
  ############################################
  mkdir -p $log_files_dir
  log_files_num=${#log_files_name[@]}
  #cut nginx log files
  for((i=0;i  自动切割nginx access日志并存放到以年 月命名的文件夹中,也可以设置自动删除30天以前的日志。
  #crontab -e
  0 0 * * * /usr/local/nginx/cut_nginx_logs.sh
  2、awstats
  修改awstats配置文件的nginx日志目录
  LogFile="/var/www/wwwlogs/%YYYY-24/%MM-24/access_%YYYY-24%MM-24%DD-24.log"
  #crontab -e
  10 0 * * * /var/www/awstats/tools/awstats_buildstaticpages.pl -update -config=cacti -lang=cn -dir=/var/www/awstats/html-awstatsprog=/var/www/awstats/wwwroot/cgi-bin/awstats.pl

页: [1]
查看完整版本: awstats 统计 nginx日志切割