I want run an scheduler at every saturday at 11.45pm, But if use whenever gem it will not support in heroku, How can we write Heroku Scheduler with Custom Intervals?
Answer:
Simple Scheduler is a scheduling add-on that is designed to be used with Sidekiq and Heroku Scheduler.It gives you the ability to schedule tasks at any interval without adding a clock process. Heroku Scheduler only allows you to schedule tasks every 10 minutes, every hour, or every day.
STEP 1: gem "simple_scheduler" STEP 2: bundle STEP 3: Create the file config/simple_scheduler.yml in your Rails project:
# Global configuration options. These can also be set on each task.
queue_ahead: 360 # Number of minutes to queue jobs into the future
tz: nil # The application time zone will be used by default if not set
# Runs once every 2 minutes
simple_task:
class: "SomeActiveJob"
every: "2.minutes"
# Runs once every day at 4:00 AM. The job will expire after 23 hours, which means the
# job will not run if 23 hours passes (server downtime) before the job is actually run
overnight_task:
class: "SomeSidekiqWorker"
every: "1.day"
at: "4:00"
expires_after: "23.hours"
# Runs once every half hour, starting on the 30 min mark
half_hour_task:
class: "HalfHourTask"
every: "30.minutes"
at: "*:30"
# Runs once every week on Saturdays at 12:00 AM
weekly_task:
class: "WeeklyJob"
every: "1.week"
at: "Sat 0:00"
tz: "America/New_York"
STEP 4: Add the rake task to Heroku Scheduler and set it to run every 10 minutes: rake simple_scheduler
For more information you can follow below link,