I’ve never actually explored log rotation tools in Linux and merely knew of the existence of logrotate and left it at that until log sizes really became a problem. Turns out logrotate is amazingly easy to configure, and thanks to this Logrotate and Mongrel blog post by Corey Donohoe I have it setup for my Rails applications that are running on Mongrel. Here’s what my /etc/logrotate.d/mongrel_cluster looks like:
/var/railsapps/APP_NAME/shared/log/production.log {
daily
rotate 28
missingok
compress
sharedscripts
postrotate
for i in `ls /var/railsapps/APP_NAME/shared/log/*.pid`; do
kill -USR2 `cat $i`
done
endscript
}
3 Responses to logrotate and mongrel (mongrel_cluster)
jeff
July 18th, 2007 at 12am
minor point, but I don’t think there’s any need to do the “ls with backticks thing” -just do a “/var/railsapps/APP_NAME/shared/log/*.pid”,and that should be fine… RESPEK for your jsonifier post, btw!!! ;P
choonkeat
July 21st, 2007 at 12pm
Like the commenters in the original post, I usually use
copytruncatewhich avoids the mongrel killings.Confluence: Site Infrastructure Group
February 29th, 2008 at 7am
Log Rotation…
Logging applications and concepts Researching various methods to do log rotation on various applications. There seems to be the following options: 1.) custom scripts 2.) Sun’s logadm…