I am using whenever gem to write a simple cron job like.
every 1.minute do
runner "ValidModel.clean"
end
I see that this cron fires at the right time but the Rails command ValidModel.clean doesn't succeed. It gives the following error:
/home/deploy/.rvm/rubies/ruby-2.4.2/lib/ruby/site_ruby/2.4.0/rubygems.rb:271:in `find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
from /home/deploy/.rvm/rubies/ruby-2.4.2/lib/ruby/site_ruby/2.4.0/rubygems.rb:299:in `activate_bin_path'
from /home/deploy/.rvm/gems/ruby-2.4.2/bin/bundle:23:in `<main>'
from /home/deploy/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `eval'
from /home/deploy/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `<main>'
I am using RVM. Is this issue related with using RVM with whenever?
Update
In gemfile I have put
gem 'whenever', require: false
When I run crontab -l
it lists the following:
PATH=/home/deploy/apps/app/shared/bundle/ruby/2.4.0/bin:/home/deploy/.rvm/gems/ruby-2.4.2/bin:/home/deploy/.rvm/gems/ruby-2.4.2@global/bin:/home/deploy/.rvm/rubies/ruby-2.4.2/bin:/home/deploy/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
GEM_PATH=""
* * * * * /bin/bash -l -c 'cd /home/deploy/apps/app/releases/20180121061036 && bundle exec bin/rails runner -e production '\''ValidModel.clean'\'' >> /home/deploy/apps/app/releases/20180121061036/log/cron.log 2>&1'
What can I try next?