Wednesday, June 17, 2009

Nginx Logrotated

ok here i wanted to share nginx logrotated run in RHEL. I run this script because iam using Dimdim with nginx engine and it store a huge log file.

Script for nginx logrotate.

Logs is located at /usr/local/dimdim/nginx/logs
Add nginx file and edit or add at /etc/logrotate.d

copy & paste this script

/usr/local/dimdim/nginx/logs/*.log {

daily
missingok
rotate 9
compress
delaycompress
notifempty
postrotate
kill -USR1 `cat /usr/local/dimdim/nginx/logs/nginx.pid`
endscript

}

restart

add rules at crontab so it can be run in time you set for the log

add
# rotating logrotate
59 23 * * * root /usr/sbin/logrotate -f /etc/logrotate.conf

done!

No comments:

Post a Comment