Scenario: a gem called 'whenever' translates ruby code to crontab commands and you write that code in a file called schedule.rb
which once run makes the translation to the crontab file.
I have a snippet in my schedule.rb
which would execute the method located in an Active Record model, every 15 minutes and then would write me a log in a tasks file saying "done" but nothing happens ever if I let the whenever do something.
The model, controller and view work fine when I manually run them on the browser, but if I leave it up to the automated mode, it won't do anything.
So, for the schedule.rb
set :output, "#{path}/tareas.log"
every 15.minutes do
rake "article.fetcharticles"
command "echo'done'"
end
which translated into the crontab file as:
0,15,30,45 * * * * /bin/bash -l -c 'cd/root/aggregrator && RAILS_ENV=development bundle exec rake article.fetcharticles --silent >> /root/aggregrator/tareas.log
The fetcharticles
method is nothing but a def within the model (article) with a curl like command which works fine, as I said, when I run it manually from firefox.
Is there anything left I should have done?
So, what other posts said was that 'whenever' did not work on development env, but in production. Well, that post was from 2011 so I hope that 'whenever' has fixed that by now, because if I try to change to server .-e production I get errors about secret key configurations etc and it won't start, so I am still on development mode.
and then another one wrote:
Are you using RVM? If so, Whenever generates a crontab entry like this (yes exactly like mine)
and his solution was:
To make this work, you need to add an appropriate .rvmrc file to your project's root folder.
but, how do I do that?
his post was here but did not get an approved answer.
Whenever cron job is not working in rails 3
UPDATE:
The problem very much seems to point in the direction of not having the needed files, maybe has something to do with this rmv issue reported, but seeing the logs of errors in my tareas.log file I see, (show a snippet)
/usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find i18n-0.7.0 in any of the sources (Bundler::GemNotFound)
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/spec_set.rb:85:in `map!'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/spec_set.rb:85:in `materialize'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/definition.rb:132:in `specs'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/definition.rb:177:in `specs_for'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/definition.rb:166:in `requested_specs'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/environment.rb:18:in `requested_specs'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/runtime.rb:13:in `setup'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler.rb:122:in `setup'
from /usr/local/rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/setup.rb:18:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /root/aggregrator/config/boot.rb:3:in `<top (required)>'
from bin/rails:7:in `require_relative'
None of the solutions provided addressed the core of the problem, as the problem is in missing files exactly as I pointed out when I wrote the initial post