1

I am trying to setup a cron job using the whenever gem. I have written when the cron job should be run in the schedule.rb and also updated the crontab as mentioned in the railscasts episode. But the cron job does not seem to be running. I am just using it in the local machine.

This is the schedule.rb code

every :sunday, :at => "2:28am" do
  runner "App.send_status", :environment => :development
end

and this is what comes when I did crontab -l

    28 2 * * 0 /bin/bash -l -c 'cd /Users/felix/cron && script/rails runner -e development 
'\''App.send_status'\'''

I setup the cron just 5 mins ahead(i.e at 2:23).

It gets executed, when I tried it from the command line like

script/rails runner -e development "App.send_status"

Could you please tell me whether I am missing something. Thanks!!!

felix
  • 11,304
  • 13
  • 69
  • 95
  • you are correct. but is there a way to correct it. it is generated by whenever gem itself – felix Dec 11 '10 at 19:41

1 Answers1

0

To debug this I would first put some puts with status text in App.send_status

Then go to server and add the following line in 'crontab -e'

MAILTO=your@email.com

All the puts output should be in your mailbox shortly after execution.

mpapis
  • 52,729
  • 14
  • 121
  • 158
  • In case you don't have an MTA installed on the server, the other way to debug it is to add this to your schedule.rb file: set :output, "#{path}/log/cron_log.txt" This will then route to the output of the cron job to file in your log directory where you can look at what's wrong. – zippy Oct 10 '12 at 15:30