Have just installed whenever gem https://github.com/javan/whenever to run my rake tasks, which are nokogiri / feedzilla dependent scraping tasks.
eg my tasks are called grab_bbc, grab_guardian etc
My question - as I update my site, I keep add more tasks to scheduler.rake.
What should I write in my config/schedule.rb to make all rake tasks run, no matter what they are called?
Would something like this work?
every 12.hours do
rake:task.each do |task|
runner task
end
end
Am new to Cron, using RoR 4.
The aggregated task can be concise:
Namespaces are also a good practice.
Make sure you have a unique namespace with all the tasks in it, like:
You could then run all tasks of that namespace with a task outside of that namespace:
That said, I'm pretty sure that this is not how you should run a set of scrapers. If for any reason the
if
part should return true you might unintenionally run tasks likerake db:drop
Either "manually" maintaining
schedule.rb
or a master task seems like a better option to me.write separate rake tasks for each scraping tasks. then write a aggregated task to run all those scraping rake tasks.
then call the rake task as
in console write $ rake sc:all