No commit activity in last 3 years
No release in over 3 years
Extends delayed_job to support recurring jobs, including timezone support
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

delayed_job_recurring_mongoid

Build Status

Extends delayed_job to support recurring jobs.

Usage

This is copy project from https://github.com/amitree/delayed_job_recurring and make it compatible with mongoid.

Add it to your Gemfile:

gem 'delayed_job_recurring_mongoid'

Then define a task class. We like the concept of interactors, so we put our task classes in app/interactors. You could also put them in lib or even app/models.

require 'delayed_job_recurring'

class MyTask
  include Delayed::RecurringJob
  run_every 1.day
  run_at '11:00am'
  timezone 'US/Pacific'
  queue 'slow-jobs'
  def perform
    # Do some work here!
  end
end

And schedule it. In a rails app, you might put this in an initializer:

MyTask.schedule! # run every day at 11am Pacific time (accounting for daylight savings)

Advanced usage

Passing options to schedule

MyTask.schedule(run_at: '12:00')

Running at multiples times each day

MyTask.schedule(run_every: 1.day, run_at: ['11:00', '6:00pm']

Running on specific days of the week

MyTask.schedule(run_every: 1.week, run_at: ['sunday 8:00am', 'wednesday 8:00am'])

Thanks!

Many thanks to @ginjo and @kares for their work! This code was derived from https://gist.github.com/ginjo/3688965.