Skip to content

Instantly share code, notes, and snippets.

@MyklClason
Last active May 29, 2016 17:03
Show Gist options
  • Save MyklClason/71477f35a1494bc87fcd07cee9d39de0 to your computer and use it in GitHub Desktop.
Save MyklClason/71477f35a1494bc87fcd07cee9d39de0 to your computer and use it in GitHub Desktop.
A trivial Rails cron job made using the Que gem
# app/jobs/cron_job.rb
class CronJob < Que::Job
# To minimize log clutter from unavailable jobs,
# @run_at should be a bit less than Que.wake_interval
@run_at = proc { 59.seconds.from_now }
def run
# Do stuff here
CronJob.enqueue
end
end
# config/initializers/que.rb
Que.mode = :async
Que.wake_interval = 60.seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment