I managed to get the cron job to run the rake task by doing the following:
cd /home/myusername/approotlocation/ && /usr/bin/rake sendnewsletter RAILS_ENV=development
I checked with which ruby and which rake to make sure the paths are correct (from bash)
the work looks like it wants to start when I receive the next 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 in 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 elements, he still gives me the same error ...
Can anyone shed some light on this? or alternatively advise me how to create a custom file in a script directory that will run this function (I already have a cron job that will run and process all my delayed_jobs.
After Jonathan's suggestion below I ran
okr
as a cron job on my own and got the following output:
SHELL=/bin/sh MAILTO=myemailaddress USER=myusername PATH=/usr/bin:/bin PWD=/home/myusername SHLVL=1 HOME=/home/myusername LOGNAME= myusername _=/usr/bin/env
Does this mean that it is not loading ruby ββfiles correctly? .... also took Jonathan's advice and released the following cron.sh file
#!/bin/sh date echo "Executing Matenia Rake Task" PATH=/usr/bin:/bin cd /home/myusername/approotlocation/ rake sendnewsletter
still get the missing gems ... Hooray!