This question will probably only make sense if you know about the whenever gem for creating cron jobs. I have a task in my schedule.rb like
every 1.day, :at =&g
Add the following line of code at top of config/schedule.rb.
ENV['RAILS_ENV'] = "#{@pre_set_variables[:environment]}"
and update the crontab using following command.
whenever --update-crontab pvcnxt --set 'environment=production'
and then finally restart crontab using command
service crond restart
Thats it!
Final config/schedule.rb looks this way
ENV['RAILS_ENV'] = "#{@pre_set_variables[:environment]}"
env :PATH, ENV['PATH']
require File.expand_path(File.dirname(__FILE__) + "/environment")
set :output, "#{Rails.root}/logs/cron_log_#{ENV['RAILS_ENV']}.log"
every 1.day, :at => '00:00 am' do
command "cd #{Rails.root}/lib/tasks && rake clean__posts_table_rake"
end