Reputation: 1829
Can someone assist me setting up a cron job using the whenever gem? I want to clear the Notifications, Conversations, and Receipts tables every 90 days from the created_at dates.
I'm not sure how to fill it in.
every 90.day, :at => '4:30 am' do
end
Upvotes: 0
Views: 90
Reputation: 2786
You are starting from a bad side. You should run task every day. The task will delete all Notification, Conversations and Receipts older than 90 days.
class Notification
scope :old, -> { where(["created_at < ?", 90.days.ago]) }
end
# schedule.rb
every 1.day do
runner "Notification.old.destroy"
end
Something like that.
Upvotes: 2