added job to purge old log files
This commit is contained in:
parent
eb198a491b
commit
5bdba5b6cc
1 changed files with 17 additions and 0 deletions
17
lib/tasks/purge_old_logs.rake
Normal file
17
lib/tasks/purge_old_logs.rake
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
namespace :debshots do
|
||||
desc 'Remove log entries older than a month'
|
||||
|
||||
task purge_old_logs: :environment do
|
||||
Rails.logger = Logger.new($stdout)
|
||||
Rails.logger.level = Logger::INFO
|
||||
# Rails.logger.level = Logger::DEBUG
|
||||
|
||||
Rails.logger.info 'Remove log entries that are older than a month'
|
||||
|
||||
count = Log.where('created_at < ?', 1.month.ago).delete_all
|
||||
|
||||
Rails.logger.info "#{count} log records purged"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue