Simple task scheduling inside a Rails application

Is there a way to set up simple task scheduling inside a rails application? There are code snippets that I want to run every hour, or every day or every week. I do not want to break them into separate scripts that I need to schedule through cron jobs. If I did this, then I would have to remember the backup scripts, and if I rebuild the server, I have to go and add all the cron jobs, it's just a little dirty for what I need.

I'm sorry that I can't just schedule tasks somewhere in my rails app and run them magically when I want! Any ideas?

+3
source share
3 answers

There are gems / plugins for this, such as rufus-scheduler or the more popular “ever” gem. I like @ douglassellers solution, although I have not heard about it.

+3
source

I am using a delayed job, "asynchronous priority queue with database support" to do something like this. Take a look at http://github.com/tobi/delayed_job

You still need to have something that runs "rake jobs: work", but this is better than having many different cron jobs. Please note that in the documentation: the run_at attribute - it looks like it can solve "a schedule of tasks somewhere in my rails application and run them when I want them to have problems."

+1

- Rails Cron (gem install rails_cron), , . , , , , .

Craken, http://github.com/latimes/craken, crontabs yaml rails. yaml, Craken , CronTab System Level . capistrano . - rails, cron OS.

0

Source: https://habr.com/ru/post/1731583/


All Articles