1. Add gem in Gemfile
Gemfile
gem 'whenever', :require => false
2. On the console, inside the project
wheneverize.
3. Define the method to be called in the cron job
app/model/user.rb
def self.employee_delete
candidates = Employee.where('status NOT IN (?) and Date(created_at) < ?', ['verification', 'confirmed'], Date.today - 3.months)
candidates.destroy_all
end
4. add file schedule.rb to the config folder
config/schedule.rb
set :output, "log/cron_log.log"
set :environment, 'staging'
every 1.day, :at => '12.00 am' do
runner 'Employee.employee_delete'
end
5. On the console
whenever --update-crontab
Gemfile
gem 'whenever', :require => false
2. On the console, inside the project
wheneverize.
3. Define the method to be called in the cron job
app/model/user.rb
def self.employee_delete
candidates = Employee.where('status NOT IN (?) and Date(created_at) < ?', ['verification', 'confirmed'], Date.today - 3.months)
candidates.destroy_all
end
4. add file schedule.rb to the config folder
config/schedule.rb
set :output, "log/cron_log.log"
set :environment, 'staging'
every 1.day, :at => '12.00 am' do
runner 'Employee.employee_delete'
end
5. On the console
whenever --update-crontab
No comments:
Post a Comment