logrotate and mongrel (mongrel_cluster)

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 Comments & TrackBacks (Add yours)

The paper doll icon that precedes each comment is an idea conceived by Vanessa Tan.

Paper doll icon
jeff's Gravatar

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

Posted by: jeff on July 18, 2007 12am

Paper doll icon
choonkeat's Gravatar

Like the commenters in the original post, I usually use copytruncate which avoids the mongrel killings.

Posted by: choonkeat on July 21, 2007 12pm

Paper doll icon
Confluence: Site Infrastructure Group's Gravatar

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…

Posted by: Confluence: Site Infrastructure Group on February 29, 2008 7am

You can subscribe to the RSS feed for comments on this post.

Post a comment

(required)

(required, but never displayed)


You can format your comments using XHTML. Your email address will not be displayed or used for nefarious purposes.

Only following tags are allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>