Tuesday 6 October 2009

rotating nginx logs

Since moving most of my systems over to plain Ubuntu on EC2 (as opposed to using ec2OnRails) I've needed to figure out certain things - like rotating the nginx logs (using Nginx instead of apache).

Simply create a file in /etc/logrotate.d/nginx that looks like this

/opt/nginx/logs/*.log {
daily
missingok
rotate 30
compress
delaycompress
sharedscripts
postrotate
/etc/init.d/nginx restart
endscript
}