Skip to content

Instantly share code, notes, and snippets.

@addywaddy
Last active August 29, 2015 14:04
Show Gist options
  • Save addywaddy/2644f28f1e3c05b7e317 to your computer and use it in GitHub Desktop.
Save addywaddy/2644f28f1e3c05b7e317 to your computer and use it in GitHub Desktop.
Whenever and Rbenv
# As cron runs with a restricted environment, we need to provide it with the correct path for our ruby
# Define the following jobs:
job_type :rbenv_rake, %Q{export PATH=/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH; eval "$(rbenv init -)"; \
cd :path && RAILS_ENV=:environment bundle exec rake :task --silent :output }
job_type :rbenv_runner, %Q{export PATH=/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH; eval "$(rbenv init -)"; \
cd :path && bundle exec rails runner -e :environment ':task' :output }
# And then use them in your schedule
every :day, at: '2am' do
rbenv_rake 'report:generate'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment