I am using Whenever gem to schedule some work on my site. Currently I am working on development environment.
I have instaled gem as guide suggests.
In schedule.rb
every 2.minutes do
rake "vip_recomend:give"
end
In lib/tasks/vip_recomend.rake
namespace :vip_recomend do
desc "Give vip recomend to ads that are in waiting list"
task give: :environment do
girls = Girl.all
girls.each do |girl|
BlacklistMailer.blacklisted(girl).deliver
end
user = User.first
UserMailer.password_reset(user).deliver
end
end
Then I tried these comands:
whenever --set environment=development --update-crontab
or
whenever --update-crontab
Nothing happens.
Then I check if cron is updated with my stuff with this:
crontab -l
Output:
# Begin Whenever generated tasks for: /home/my_host/blogs/config/schedule.rb
* * * * * /bin/bash -l -c 'cd /home/my_host/blogs && RAILS_ENV=development bundle exec rake vip_recomend:give --silent >> /log/cron_log.log 2>&1'
# End Whenever generated tasks for: /home/my_host/blogs/config/schedule.rb
When I try to run rake task from console it works.
Any help on this? Thanks.
Update 1
when in schedule.rb I have this
env :PATH, ENV['PATH']
In cron error logs I get this message.
/opt/alt/ruby21/lib64/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'bundler' (>= 0) among 8 total gem(s) (Gem::LoadError)
from /opt/alt/ruby21/lib64/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
from /opt/alt/ruby21/lib64/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /home/individualki/rubyvenv/ror/2.1/bin/bundle:22:in `<main>'
SOLUTION:
I changed Whenever to Rufus-scheduler.
Before that I tried EVERY possible solution to fix my problem. I think problem was in my Ruby installation on shared hosting, but I didn't have time to examine it.