开发者

scheduling sequential tasks with whenever gem

i'm using whenever to schedule tasks for a rails application.

I have a task like:

every 24.hours d开发者_StackOverflow中文版o
   command "do_this"
   rake "do_that"
end

my point is, when i write it to my crontab, with whenever -w, i see that it generates two independent tasks running at the same time. the problem is, both are logically a sequence, that means, the rake task, "do_that", should run just if the command "do_this" did already, successfully run.

I tried to contact both like command "do_this" && rake "do_that" but i received a syntax error.

  • Does exist any trick to create this dependence between tasks in whenever?

  • Does the crontab execute the jobs at same time, in parallel or it process N tasks scheduled at the same time in a queue?


I think there are two things you could do:

(1) Run the command from the rake task:

task :do_that => :environment do
  system "do_this"
  ...
end

And simplify your schedule.rb file to:

every 24.hours do
   rake "do_that"
end

(2) Run everything from the command line:

every 24.hours do
  command "do_this && rake do_that"
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜