旌旗博客

2009-01-12

Make cronolog work with Nginx

Filed under: I.T. — 标签: — rocky @ 23:02

I got two solutions from here: http://pjkh.com/articles/2007/03/15/nginx-and-cronolog/.

But I am not satisfied with the second solution because of some wrong placement with a few log records. I would like use this:

mv /var/log/nginx/access_log /var/log/nginx/access_log.processing -f;
mv /var/log/nginx/error_log /var/log/nginx/error_log.processing -f;
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`;
/usr/bin/perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -LogFile=/var/log/nginx/access_log.processing -update
cat /var/log/nginx/access_log.processing | /usr/local/sbin/cronolog /var/log/nginx/%Y/%m/%d/access_log;
cat /var/log/nginx/error_log.processing | /usr/local/sbin/cronolog /var/log/nginx/%Y/%m/%d/error_log;
rm /var/log/nginx/access_log.processing /var/log/nginx/error_log.processing -f;

Powered by WordPress