saranya elumalai
saranya elumalai

Reputation: 459

Rufus scheduler fires at the scheduled time (expected ) and fires again after completion of previous run

I have scheduled rufus cron to run a method (a method to post a complex query in remote DB, retrieves result and, do some processing ) every hour and 99% of time the methods completes execution <1 hr.

Rufus fires the method fine at every expected time, but the problem is some times (1% fo time) the method wont complete in a hour; the scheduler fires the second one at the expected time and fires the second one again, on completion of previous run.

For example,

pin_sampling_job_scheduler = Rufus::Scheduler.new pin_sampling_job_scheduler.cron("22 * * * *") do puts "sampling starts" DatafetchRedshift.pin_sampling_job end

for hour = 00, the method fires at 22nd min(as expected and assume the job is running for 1.5 hour) For hour =01, method is fires at 22nd min and again at 52nd min (after completion of first run). Why is it happening like this? Any help or suggestion will be appreciated.

Rufus version -3.3.4 Rails - 4.1.6 Ruby 2.2.0

P.S - I wont be able to change the scheduler runs to be more than an hour, since 99% it completes

Upvotes: 0

Views: 237

Answers (1)

jmettraux
jmettraux

Reputation: 3551

https://github.com/jmettraux/rufus-scheduler#overlap--false

pin_sampling_job_scheduler = Rufus::Scheduler.new

pin_sampling_job_scheduler.cron("22 * * * *", overlap: false) do
  ts = Time.now.strftime('%Y%m%d%H%M')
  puts "#{Time.now} - sampling #{ts} starts..."
  DatafetchRedshift.pin_sampling_job
  puts "#{Time.now} - sampling #{ts} stopped."
end

for hour = 00, the method fires at 22nd min(as expected and assume the job is running for 1.5 hour) For hour =01, method is fires at 22nd min and again at 52nd min (after completion of first run). Why is it happening like this?

You can report issues at https://github.com/jmettraux/rufus-scheduler/issues (please read https://github.com/jmettraux/rufus-scheduler#getting-help before filing an issue)

Upvotes: 1

Related Questions