0

I am trying to execute one task for development evironment every minute using whenever gem. I followed all the steps given in documentation for my rails 4 application. This is my schedule.rb file

every 1.minute do
 runner "User.resend_confirmation_instructions_to_user", :environment => :development
end

an in my User model I have this code

def resend_confirmation_instructions_to_user    
  user = User.find_by_email("abcdef905@gmail.com")
  user.send_confirmation_instructions
end

and then according to documentation i updated my crontab. its not giving me an error but also i am not getting any output. I simply followed this link http://eewang.github.io/blog/2013/03/12/how-to-schedule-tasks-using-whenever/

Hemant Patil
  • 331
  • 2
  • 18

1 Answers1

0

Make sure you have working email configuration in development.rb file.

Also after adding new task restart the server and schedule the task again.

Hassan Ahmed
  • 168
  • 2
  • 9
  • Yes, I tried it. nothing helped me. forget about emails , even if i write simple puts statement , nothing gets logged into my log file. – Hemant Patil Oct 17 '15 at 12:26
  • and what do you mean by schedule the task again? I am simply updating crontab by simply runnig whenever --update-crontab – Hemant Patil Oct 17 '15 at 12:33
  • * * * * * /bin/bash -l -c 'cd /home/hemant/hemant/new_travelibro && bin/rails runner -e development '\''User.resend_confirmation_instructions_to_user'\'' >> /log/cron_log.log 2>&1' – Hemant Patil Oct 17 '15 at 12:36
  • "resend_confirmation_instructions_to_user" is defined as instance method, you should change it to class method as "self.resend_confirmation_instructions_to_user" – Hassan Ahmed Oct 17 '15 at 12:42
  • check the log file cron_log, if it says "Permission denied" try http://stackoverflow.com/questions/19463908/whenever-cron-not-working-permission-denied – Hassan Ahmed Oct 17 '15 at 12:52
  • also schedule a rake task instead of runner in shcedule.rb file, it's much simpler – Hassan Ahmed Oct 17 '15 at 12:54