1

I have started using the Whenever gem to schedule cron jobs with rails.

But sadly rake will not run, I traced the problem to the environment not being loaded.

The whenever gem generates scripts like:

/bin/bash -l -c '....

I managed to get it to work with

/bin/bash -i -c '...

[The change is -i (interactive) instead of -l (login)]

Based on the documents of cron, their syntax is correct. Can anyone give a hint to why it might fail on Ubuntu 10.4 ?

Thanks

Boris
  • 3,163
  • 5
  • 37
  • 46
  • May be you had the same problem with me http://stackoverflow.com/questions/13410245/connection-refuse-when-sending-mail-with-cron-tab/13638766#13638766 – duykhoa Nov 30 '12 at 03:57

1 Answers1

1

As you're using whenever gem, first of all, create a :cron task, which would be something like this:

task :cron => :environment do

    Rake::Task['db:your-development-env'].invoke

end

Then in your config/schedule.rb, setup your time of backup:

set :output, "/tmp/cron_log.log"
every 1.day, at: '1:00 am' do; rake 'cron'; end 

To pass the settings to crontab:

whenever --update-crontab
j0k
  • 22,600
  • 28
  • 79
  • 90
anupamc
  • 21
  • 2