Skip to content

Instantly share code, notes, and snippets.

@ryenski
Created April 27, 2018 00:33
Show Gist options
  • Save ryenski/328a65c81fbc86ee8a438134e9c643be to your computer and use it in GitHub Desktop.
Save ryenski/328a65c81fbc86ee8a438134e9c643be to your computer and use it in GitHub Desktop.
# 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
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