: 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.