hugoabonizio / schedule.cr

:clock3: Run periodic tasks in Crystal

Home Page:https://hugoabonizio.github.io/schedule.cr/Schedule.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

run tasks on a specific day of the week

tonyvince opened this issue · comments

Is there a way that I can run tasks on a specific day of the week, say every Tuesday?
I have been using the whenever gem and it has a nice option to do that

every :sunday, :at => '12pm' do # Use any day of the week or :weekend, :weekday
  runner "Task.do_something_great"
end

Hi @tonyvince, thank you for the suggestion!

I think it's a nice feature and have plans to implement it sometime, but if you want to tackle on this, feel free to send a PR! 😄

@tonyvince There's a new release that includes this feature, do you wanna take a look? 😃

Now it's possible to do things like this:

Schedule.every(:day, "16:00:00") do
  puts "Good Afternoon!"
end

And use days of the week, as you suggested:

Schedule.every(:sunday, "16:00:00") do
  puts "House Keeping"
end