Abhi On Rails

Ruby On Rails - What I learned recently

Cron Job

Cron is a time based job scheduler. Cron job is a job scheduled to run at particular time. In rails you may need to create cron jobs in many situations. For example send account expiration mail, check account balance and inform the user, etc. There is a gem 'Whenever', which allows you to create a cron job.

Whenever

Using whenever you can easily create cron jobs. First you have to install the gem:
gem install whenever

Then from your application path type:
whenevrize .
This will create the file 'config/schedule.rb'.

In scedule.rb file you can write your cron job:
every 1.day, :at => '12:00 AM' do
   runner "Model.method"
end 
this will run the method inside the Model everyday at 12:00 AM.


For more details visit GitHub

blog comments powered by Disqus
through association →
← Delayed Job