I'm using whenever and dynamic_sitemaps gems to generate sitemaps.
here's my schedule.rb
job_type :rake, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec rake :task --silent :output"
job_type :script, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec script/:task :output"
job_type :runner, "{ cd #{@current_path} > /dev/null; } && RAILS_ENV=:environment bundle exec rails runner ':task' :output"
set :output, "#{path}/log/cron.log"
every 1.day, :at => '5:30 am' do
rake "sitemap:generate"
end
if I use "bundle exec rake sitemap:generate RAILS_ENV="production"
" my sitemap is generated properly.
`bundle exec whenever RAILS_ENV="production"` seems to be working too
-
30 5 * * * /bin/bash -l -c '{ cd > /dev/null; } && RAILS_ENV=production bundle exec rake sitemap:generate --silent >> /var/www/.*******.log 2>&1'
## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.
But when I check cron.log on another day(after 5:30) I see this message
Could not locate Gemfile or .bundle/ directory
So, the new sitemap wasn't generated. How can I fix this?
already tried this solution but it didn't work for me or I'm doing something wrong.
I installed ruby with rvm
UPDATE
So, I made it working. And here's what I did:
ls /usr/local/rvm/wrappers/
This gave me a list of wrappers/aliases that I have. One of them was ruby-2.2.2
then I edited my schedule.rb
set :output, "#{path}/log/cron.log"
job_type :runner, "cd #{path} && RAILS_ENV=production /home/$USER/.rvm/wrappers/ruby-2.2.2/bundle exec rails runner ':task' :output"
every 1.day, :at => '4:30 am' do
rake "sitemap:generate"
end
and run bundle exec whenever --update-crontab RAILS_ENV="production"
from the app directory(current).
UPD 2017
rvm cron setup
might be helpful too