Reputation: 183
One method would be to use cron job. https://github.com/javan/whenever.
Is there any other way to do this?
Upvotes: 0
Views: 106
Reputation: 1373
Also you can use any background workers familar with ruby on rails. For example sidekiq and rescue. Both have plugins for working with periodical tasks
sidekiq: sidetiq - Great choice. It has perfect interface integrated in standard sidekiq monitoring tool. I use it on all my projects.
resque: resque-scheduler - I used this scheduler couple years ago. All I know about it, it does its work well.
Upvotes: 1
Reputation: 218960
If you consider cron
to be "one way" to do this then yes, there are countless "other ways". This is because all of these ways would essentially be doing the same thing... Scheduling a task to run at periodic intervals.
Don't think of cron
or any other scheduling tool as part of the application. Separate the concerns of "performing the task" from the concerns of "scheduling the task." Once you have an application which performs the task (and if the task in this case is just incrementing some persisted value then the entire application is going to be quite small) then separately you would use a scheduling system to schedule the task.
cron
can do this. So can countless others. You could even write your own scheduler to run as a daemon or background service of some kind (the terminology depends on the platform, and platform differences regarding schedulers is a key reason to keep the concerns separated).
Upvotes: 1