Nginx or tengine access log split processing

Source: Internet
Author: User
When using Naginx is an access log that is becoming huge and can reach the GB level, so we need to split,

I'm breaking it down by time.

#!/bin/bash# Access log file location nginx_path= "/usr/local/nginx/logs/" bak_path= "/usr/local/nginx/logs/dowload/" #本程序log位置 Contains the file name log_path= "/usr/local/nginx/logs/mv_log.log" #文件夹名称英文逗号分隔access_name = "DIR1,DIR2,DIR3,DIR4,DIR5,DIR6" #nginx PID file location nginx_pid_path= "/usr/local/nginx/logs/nginx.pid" date=$ (date +%y-%m-%d) log_time=$ (date +%y-%m-%d_%h:%m:%s) echo "Time ${date}" echo $log _timeold_ifs= "$IFS" ifs= "," arr= ($access _name) ifs= "$OLD _ifs" echo "###################### # MV Log ${log_time} ##################################### ">>${log_path}for s in ${arr[@]}do src_path= $nginx _p Ath "/" $s "/" Access_$s.log #echo $nginx _path "/" $s "/" Access_$s.log Echo "# # # # ($s) _ Start_${log_time} # # # # # >> ${l Og_path} If [-F ' $src _path "];        Then MV $src _path $bak _path$s "/" Access_${log_time}.log 2>> ${log_path} #防止文件过大或过多 each copy and send variable KILL-USR1 ' Cat ${nginx_pid_path} ' #echo $s move Success ">>${log_path} else Echo" # # ($s) _not_find_fil E_${log_time} # # ">> ${log_Path} fi echo "# # # ($s) _end_${log_time} ######" >> ${log_path} echo "" >>${log_path}doneecho "###### ################## END LOG ################################################# ">> ${log_path}echo" ">>${ Log_path}echo "" >>${log_path}

The above describes the Nginx or tengine access log segmentation processing, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.