Nginx log rollback-Linux Enterprise Application-Linux server application information. The following is a detailed description. Author: shunz, source: http://shunz.net/2008/07/nginx_log_rotation.html
Nginx is a Web server software developed using the new Linux 2.6 kernel epoll mechanism, which can greatly improve the I/O performance of Web access, especially small file access. It is a solution to the c10k problem. According to some tests, Nginx is 10 times more efficient than Apache, and from my previous tests, its concurrency performance is indeed much better than Apache. Nginx is short and concise, so although some core web functions are well supported, some expansion functions are not supported yet. For example, Nginx currently does not support log output through pipe, therefore, cronolog is not supported for log truncation and rollback by time. An alternative solution is provided below:
CODE :#! /Bin/sh
Log_dir = "/var/log/httpd"
Yesterday = 'date + % Y % m % d-d'-1 day''
Lastday = 'date + % Y % m % d-d'-1 month''
/Bin/rm $ {log_dir}/access. $ {lastday}. log
/Bin/rm $ {log_dir}/error. $ {lastday}. log
/Bin/mv $ {log_dir}/access. log $ {log_dir}/access. $ {yesterday}. log
/Bin/mv $ {log_dir}/error. log $ {log_dir}/error. $ {yesterday}. log
Kill-USR1 'cat/var/run/nginx. Pi'
/Bin/gzip $ {log_dir}/access. $ {yesterday}. log &
/Bin/gzip $ {log_dir}/error. $ {yesterday}. log & |