I created a simple task, which runs a method from the controller via gem "whenever".
set :environment, :development
env :PATH, ENV['PATH']
set :output, { :error => "log/error.log", :standard => 'log/cron.log' }
every 2.minutes do
runner "ParserController.test1"
end
def self.test1
puts "HELLO PARSER"
end
When I execute whenever --update-crontab and wait for 2 minutes I got an error in the log:
bundler: not executable: bin/rails
I tried to run the command without cron and got 2 different results:
The first variant is
bundle exec bin/rails runner -e development 'ParserController.test1'
'bundler: not executable: bin/rails'
The second variant is
bundle exec rails runner -e development 'ParserController.test1'
HELLO PARSER
try adding env :GEM_PATH, ENV['GEM_PATH']
set :environment, :development
env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']
set :output, { :error => "log/error.log", :standard => 'log/cron.log' }
every 2.minutes do
runner "ParserController.test1"
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.