Reputation: 345
I am using resque for job scheduling. I want to run a job every 1 hour and for N times only. I also want to pass count in the job as argument
for example:
i=0
50.times do
every 1.hour, roles: [:whenever_cron] do
runner "Resque.enqueue(SomeJob, i+1)"
end
end
How can I do this?
Note : - I don't want to run 50 jobs every hour. I want to run 1 job 50 times
Upvotes: 0
Views: 651
Reputation: 230276
Scheduling syntax is for recurring jobs. Those that happen over and over again, until the end of times.
For single-shot jobs, you enqueue them, with an optional delay (which is what you need here). So you can just enqueue the whole batch of your jobs all at once, with 1 hour increments:
1.upto(50).each do |x|
Resque.enqueue_in(x.hours, SomeJob)
end
Upvotes: 2