Nginx or tengine access log segmentation

Source: Internet
Author: User
: This article describes how to split nginx or tengine access logs. For more information about PHP tutorials, see. When using Nagars, the access logs become larger and can reach the GB level. Therefore, we need to split them,

Here I split it by time,

#! /Bin/bash # access log file location nginx_path = "/usr/local/nginx/logs/" bak_path = "/usr/local/nginx/logs/dowload/" # This program log location contains the file name log_path = "/usr/local/nginx/logs/mv_log.log" # folder names separated by commas (,) 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_path "/" $ s "/" access _ $ s. log # echo $ nginx_path "/" $ s "/" access _ $ s. log echo "#### ($ s) _ start _ $ {log_time }####" >$ {log_path} if [-f "$ src_path"]; then mv $ src_path $ bak_path $ s "/" access _ $ {log_time }. log 2 >>$ {log_path} # prevent too many or too many files from copying and sending the variable kill-USR1 'cat $ {nginx_pid_path} '# echo "$ s move Success"> $ {log_path} else echo "# ($ s) _ NOT_FIND_FILE _ $ {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 preceding sections describe how to split nginx or tengine access logs, including some content. if you are interested in the PHP Tutorial.

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.