rake task via cron problem loading rubygems
Posted
by Matenia Rossides
on Stack Overflow
See other posts from Stack Overflow
or by Matenia Rossides
Published on 2010-04-06T13:45:56Z
Indexed on
2010/04/06
14:03 UTC
Read the original article
Hit count: 336
I have managed to get a cron job to run a rake task by doing the following:
cd /home/myusername/approotlocation/ && /usr/bin/rake sendnewsletter RAILS_ENV=development
i have checked with which ruby
and which rake
to make sure the paths are correct (from bash)
the job looks like it wants to run as i get the following email from the cron daemon when it completes
Missing these required gems:
chronic
whenever
searchlogic
adzap-ar_mailer
twitter
gdata
bitly
ruby-recaptcha
You're running:
ruby 1.8.7.22 at /usr/bin/ruby
rubygems 1.3.5 at /home/myusername/gems, /usr/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
(in /home/myusername/approotlocation)
my custom rake file within lib/tasks is as follows:
task :sendnewsletter => :environment do
require 'rubygems'
require 'chronic'
require 'whenever'
require 'searchlogic'
require 'adzap-ar_mailer'
require 'twitter'
require 'gdata'
require 'bitly'
require 'ruby-recaptcha'
@recipients = Subscription.all(:conditions => {:active => true})
for user in @recipients
Email.send_later(:deliver_send_newsletter,user)
end
end
with or without the require items, it still gives me the same error ...
can anyone shed some light on this? or alternatively advise me on how to make a custom file within the script directory that will run this function (I already have a cron job working that will run and process all my delayed_jobs.
Cheers!
© Stack Overflow or respective owner