Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

(Hope I have the right SE site for this question, apologies if not.)

I have a Ruby-on-Rails application that is deployed using Apache+mod_rails (passenger). It uses MySQL for the database backend. I'm using SyslogLogger to send the RoR log to syslog and using logrotate via a daily cron job to rotate the logs.

What I've found is that the RoR app hangs if it is in the middle of something when the logs are rotated. I've tried putting copytruncate in the logrotate configuration, but it appears that this also affects the apache logs (maybe because the RoR error logs go to the error.log file of apache) and - possibly - also the MySQL logs (maybe - it's sometimes hard to correlate exactly which log causes the crash).

Searching on the internet turns up some different solutions on log rotation, one is to use the copytruncate key, another is to use cronolog, but I've yet to find one that directly addresses the issue I'm seeing.

So is there a known solution for this? What is the "right way" to rotate logs on a RoR application (using apache and mod_rails for deployment)? Should I just put copytruncate in every logrotate configuration file that is vaguely related with the application?

share|improve this question

Instead of 'copytruncate', these lines worked for me in the logrotate file for my rails app:

    touch /your-rails-directory/tmp/restart.txt
share|improve this answer

I wouldn't bother sending your Rails app's logs to syslog. Have you tried your logrotate config when letting Rails write its own log files?

share|improve this answer
I use syslog to keep the log files in a reasonable order. Since I'm running rails via passenger, I can have several copies of the rails program writing to the same log file. Syslog nicely deals with these, adding process IDs and other useful information. The default rails logger just shoves it all in the same file with no extra information. I'm not a rails programmer, so I found it easier to use syslog to add the extra information than try to dig deep in the code to fix that. – Loop Space Dec 5 '10 at 19:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.