-1

I am looking at https://github.com/jmettraux/rufus-scheduler which nicely allows me to schedule and chain events.

But I want the events to stop after, say, the 10th occurrence or after the 24 days.

How do I do this?

My case would be:

run a script which creates the recurring jobs based on intervals and then stops after a given date or occurrence.

This is what I have done.

def run_schedule(url, count, method, interval)
  puts "running scheduler"

  scheduler = Rufus::Scheduler.new

  scheduler.every interval do
    binding.pry
    attack_loop(url, count, method)
  end
end

I am testing my site and want the attack_loop to be scheduled in memory to run against the interval.

But it appears it never hits the binding.pry line.

sameera207
  • 16,547
  • 19
  • 87
  • 152
Satchel
  • 16,414
  • 23
  • 106
  • 192
  • What do you mean by "testing my site"? Is this running in a web application? If yes, please give more information. As your question stands it is not properly answerable. http://www.catb.org/~esr/faqs/smart-questions.html – jmettraux Feb 06 '17 at 23:55

2 Answers2

0

Normally these schedulers are running via cron jobs. Then the problem with your requirement is cron job doesn't know whether you hit the 10th occurrence or the 24 days as it doesnt keep a track. One possible solution would be to create a separate table to update the cron job details.

I'm thinking a table like,

scheduler_details

- id
- occurrence_count
- created_date
- updated_date
_ scheduler_type

So, now when you run a script, you can create or update the details. (You can search the script by scheduler_type, that way

  • you can check the number of occurrences
  • with created date, you can calculate the 24 days

HTH

sameera207
  • 16,547
  • 19
  • 87
  • 152
0

Good day, you can specify the number of times a job should run:

https://github.com/jmettraux/rufus-scheduler/#times--nb-of-times-before-auto-unscheduling

If you need a more elaborate stop condition, you could do:

scheduler.every interval do |job|
  if Time.now > some_max_date
    job.unschedule
  else
    attack_loop(url, count, method)
  end
end

But it appears it never hits the binding.pry line.

What has it to do with your issue title? Are you mixing issues?

jmettraux
  • 3,511
  • 3
  • 31
  • 30