Created
April 27, 2018 00:33
-
-
Save ryenski/328a65c81fbc86ee8a438134e9c643be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run every day at midnight | |
# cd into the Rails app directory | |
# run the rake task `logs:prune` | |
0 0 * * * cd /Users/you/projects/myrailsapp && /usr/local/bin/rake RAILS_ENV=production logs:prune |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :logs do | |
desc "Prune request logs older than 7 days" | |
task prune: :environment do | |
RequestLog.where("created_at < ?", 7.days.ago).delete_all | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment