looking for some solutions? You are welcome.

SOLVED: Schedule task using whenver with custom time

karan:

config/schedule.rb

def timezoned time
  Time.zone = "Pacific Time (US & Canada)"
  Time.zone.parse(time).utc
end

every 1.day, at: timezoned('5:30 am') do
  runner 'App1::Task1.perform_async'
end

every 1.day, at: timezoned('5:31 am') do
  runner 'App1::Task2.perform_async'
end

every 1.day, at: timezoned('5:33 am') do
  runner 'App2::Task1.perform_async'
end

every 1.day, at: timezoned('5:34 am') do
  runner 'App2::Task2.perform_async'
end

every 1.day, at: timezoned('5:36 am') do
  runner 'App3::Task1.perform_async'
end

every 1.day, at: timezoned('5:37 am') do
  runner 'App3::Task2.perform_async'
end

every 1.day, at: timezoned('5:40 am') do
  runner 'App4::Task1.perform_async'
end

every 1.day, at: timezoned('5:41 am') do
  runner 'App4::Task2.perform_async'
end

every 1.day, at: timezoned('5:42 am') do
  runner 'App4::Task3.perform_async'
end

every 1.day, at: timezoned('5:43 am') do
  runner 'App5::Task4.perform_async'
end

I am using Sidekiq with whenever gem to schedule the jobs in Rails. Above is my schedule.rb. Is there way to schedule the tasks in a better way than the above? (e.g time + 1.minute or time + 2.minutes)

It will be helpful if any better approach for scheduling task that the above.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent