Nginx Daily log volume is relatively large, it is best to automatically cut and store every day, so that you can query and analysis of the future
#!/bin/sh####################filename: nginx_log_rotate.sh#vsersion: 0.1v#1 0 * * */bin/sh/home/project/monitor/nginx_log_rotate.sh >/dev/null 2>&1###################Logs_path="/usr/local/openresty/nginx/logs"Old_logs_path=${logs_path}/oldnginx_pid= ' cat/usr/local/openresty/nginx/logs/nginx.pid ' time_stamp= ' date- D"Yesterday"+"%y-%m-%d"' Mkdir-p${old_logs_path}#grep some mode file forFileinch' ls$logs _path| grep log$ | Grep-v' ^20 '` Doif[ !- F${old_logs_path}/${time_stamp}_$file] Thendst_file="${old_logs_path}/${time_stamp}_$file"Elsedst_file="${old_logs_path}/${time_stamp}_$file. $$"fiMv$logs _path/$file$DST _file#gzip-F $dst _file # do something with access.log.0 DoneKill-usr1$nginx _pid
Copyright NOTICE: This article is Orangleliu (http://blog.csdn.net/orangleliu/) original article, the article reproduced please declare.
The above describes the [Nginx] daily automatic cutting log script, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.