Search code examples
ruby-on-railsscheduled-tasksdelayed-job

how to create a delayed job in rails to run at one year interval?


I want to create a delayed job which will run after one year interval continuously? That is at particular date on every year. How can i achieve this using delayed job?


Solution

  • Use delay-jobs gem, so you can add time of running as params as the following:

    Notifier.delay(run_at: 1.years.from_now).signup(@user)
    

    See RailsCasts for delay-jobs

    For run this code as daily tasks, you need to read Resque gem, resque-scheduler gem, and see helpful question