Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Schedule script for using Whenever toghether with rbenv
# Schedule script for using Whenever toghether with rbenv
#
# Whenever: https://github.com/javan/whenever
# rbenv: https://github.com/sstephenson/rbenv
set :env_path, '"$HOME/.rbenv/shims":"$HOME/.rbenv/bin"'
# doesn't need modifications
# job_type :command, ":task :output"
job_type :rake, %q{ cd :path && PATH=:env_path:"$PATH" RAILS_ENV=:environment bin/rake :task --silent :output }
job_type :runner, %q{ cd :path && PATH=:env_path:"$PATH" bin/rails runner -e :environment ':task' :output }
job_type :script, %q{ cd :path && PATH=:env_path:"$PATH" RAILS_ENV=:environment bundle exec bin/:task :output }
# tasks
every 1.day, :at => Time.now + 1.minute do
rake "my:task"
runner "puts 'hello from runner'"
script 'hello'
end
@hafizio
Copy link

hafizio commented Oct 29, 2015

I still can't get this to work. How do I check if my cron job is running?

@puttpotsawee
Copy link

I made whenever log out to file,
and found out that script/rails was not found.
so I changed it to
job_type :runner, %q{ cd :path && PATH=:env_path:"$PATH" bin/rails runner -e :environment ':task' :output }

and it worked! thankss

@mitchellrw
Copy link

sweet. worked for me.

Thank you.

@The-G
Copy link

The-G commented Jan 12, 2017

it's work for me.

Thank you!!

@ahbou
Copy link

ahbou commented Oct 10, 2017

Rails 5 dropped rake in favor of Rails.
I declared a new job_type:
job_type :rails, %q{ cd :path && PATH=:env_path:"$PATH" RAILS_ENV=:environment bundle exec rails :task --silent :output }

@mdesantis
Copy link
Author

Updated. Thanks!

@wojkos
Copy link

wojkos commented Jun 24, 2019

Thank you! After hours I found your code. Work great!

@juansecaro
Copy link

With this I get the runner working but not rake
"rake aborted!
Don't know how to build task"

@jjy05
Copy link

jjy05 commented Jul 14, 2021

It works for me!!!Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment