0

I am using Whenever gem with rails. For some reason the first cronjob does not work. If i copy paste the command into the shell manually, it works as it should.

The second "touch testing123.txt" also works fine.

I have no idea why the GiftPackage.do_scheduled_deliveries rails method does not run. I'm really at a loss right now.. any help would be greatly appreciated!

# Begin Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && script/rails runner -e staging '\''GiftPackage.do_scheduled_deliveries'\'''
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && touch testing123.txt'
# End Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb

Thanks! :)

Kirk
  • 1,521
  • 14
  • 20

2 Answers2

0

Most likely you are getting an error within the app itself.

First step would be, run the task in the console using the staging environment.

Second would be to check the cron logs and see if it is outputting any errors.

You can set whenever to log output by adding the following to your schedule.rb file;

set :output, "/[path to log]/cron.log"

This should help you get closer to finding the solution.

lardawge
  • 626
  • 1
  • 5
  • 4
0

Try setting your PATH variable before the jobs, your cron is probably not able to find ruby :

For instance :

PATH=/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/$
# Begin Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && script/rails runner -e staging '\''GiftPackage.do_scheduled_deliveries'\'''
*/1 * * * * /bin/bash -l -c 'cd /var/www/mysite/releases/20130131200554 && touch testing123.txt'
# End Whenever generated tasks for: /var/www/mysite/releases/20130131200554/config/schedule.rb
Intrepidd
  • 19,772
  • 6
  • 55
  • 63
  • That does no good because it gets wiped out by whenever. Best beet is to set the path in whenever: env :PATH, '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' – lardawge Feb 01 '13 at 00:29