Skip to content

Instantly share code, notes, and snippets.

@hectorperez
Last active August 29, 2015 14:01
Show Gist options
  • Save hectorperez/6667f7e2ea558e46030f to your computer and use it in GitHub Desktop.
Save hectorperez/6667f7e2ea558e46030f to your computer and use it in GitHub Desktop.
logrotate
/etc/logrotate.conf
/etc/logrotate.d/...
/home/deploy/APPNAME/current/log/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
copytruncate
}
How It Works:
daily – Rotate the log files each day. You can also use weekly or monthly here instead.
missingok – If the log file doesn’t exist, ignore it
rotate 7 – Only keep 7 days of logs around
compress – GZip the log file on rotation
delaycompress – Rotate the file one day, then compress it the next day so we can be sure that it won’t interfere with the Rails server
notifempty – Don’t rotate the file if the logs are empty
copytruncate – Copy the log file and then empties it. This makes sure that the log file Rails is writing to always exists so you won’t get problems because the file does not actually change. If you don’t use this, you would need to restart your Rails application each time.
http://excid3.com/blog/logrotate-rails-production-logs/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment