I have my resque_scheduler set run clean up task every 2 min. The clean up task will clean up items in the 2 min interval. This is my yml:
scheduled_tasks:
cleanup:
class: "BackgroundJobs::Cleanup"
every: "120s"
description: "cleans up items in the 2 min interval"
Here's the job
module BackgroundJobs
class Cleanup
@queue = :cleanup
def self.perform(options = {})
# do cleanup here
end
end
end
The job queues fine and is picked up fine. However, in the perform, it needs to know what period it's supposed to cleanup. For exampled, if something is queued at 2:32, I want it to clean up items from 2:30 to 2:32. However, the job might not be picked up until much later, e.g. 2:35. I have no information about when it was queued. Is there a way to do this?
I think resque-status might help.