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?
Asked
Active
Viewed 2,459 times
3 Answers
1
Use whenever gem. Here is good screenacast

Grosefaid
- 138
- 1
- 7
-
1I agree with @grosefaid. You don't want to use Delayed Job for this. Use a gem like `whenever`, which is a nice ruby abstraction for `cron`. – Daiku Aug 25 '14 at 13:28
0
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)
For run this code as daily tasks, you need to read Resque gem, resque-scheduler gem, and see helpful question

Community
- 1
- 1

Mohamed Yakout
- 2,868
- 1
- 25
- 45
-
Thank you for answer. But it will run only once? I want to run it at a particular date on every year. – Kavitha Velayutham Aug 25 '14 at 13:08
-
I update my solution to make daily task for running the previous code, I hope it'll be helpful :) – Mohamed Yakout Aug 25 '14 at 14:12
0
Personally I like rufus-scheduler. From the documentation you'll have a lot of ways to schedule your tasks:
require 'rufus-scheduler'
scheduler = Rufus::Scheduler.new
# ...
scheduler.in '10d' do
# do something in 10 days
end
scheduler.at '2030/12/12 23:30:00' do
# do something at a given point in time
end
scheduler.every '3h' do
# do something every 3 hours
end
scheduler.cron '5 0 * * *' do
# do something every day, five minutes after midnight
# (see "man 5 crontab" in your terminal)
end
Also, be aware that if you kill you application, it will loose the schedule, so it's advised to save the information on database and retrieve it on startup.

Paulo Fidalgo
- 21,709
- 7
- 99
- 115