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.