5

Currently I run this code:

every 1.day, at: '2am' do
  rake 'data:load_direct_monitoring_statistics'
end if @environment == 'production'
every 1.day, at: '2pm' do
  rake 'data:load_direct_monitoring_statistics'
end if @environment == 'production'

This code works as intended, but: is there a way to use just one cron declaration to cover both cases?

Vogel612
  • 5,620
  • 5
  • 48
  • 73
Luis Masuelli
  • 12,079
  • 10
  • 49
  • 87
  • 4
    Your question did not fit very well within the framework of Code Review in its current form, as you are asking a specific programming question, rather than a general review of your code. See [this](http://codereview.stackexchange.com/help/how-to-ask) for reference. We elected to migrate it to Stack Overflow for this reason. – Phrancis Mar 16 '16 at 15:02

1 Answers1

3

According to test in whenever repository you should be able to pass Array

every "weekday", :at => %w(5:02am 3:52pm) do

Here is the source> https://github.com/javan/whenever/blob/334cfa01f373006cc032e23907b1777a8ea3f3b0/test/functional/output_at_test.rb

So in you case it should be ok to do like

every 1.day, at: ['2am','2pm'] do
  rake 'data:load_direct_monitoring_statistics'
end if @environment == 'production'
Ragnarokk
  • 71
  • 3