前提・実現したいこと
herokuにデプロイしているrailsアプリ上において、wheneverでrakeタスクを定時実行をしたいと思うのですが、schedule.rbで設定したrakeタスクが実行されていない。
原因を調べようとしたところ
$ heroku run whenever Running whenever on ⬢ サービス名... up, run.8952 (Free) 0 3 * * * /bin/bash -l -c 'cd /app && RAILS_ENV=production bundle exec rake check_expired_coupons:check_coupons --silent' 0 3 * * * /bin/bash -l -c 'cd /app && RAILS_ENV=production bundle exec rake check_expired_coupons:check_expired_coupons --silent' ## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated. ## [message] Run `whenever --help' for more options.
とあったので、
whenever --update-crontab
が必要だと思ったのですが、エラーが出て実行できません。
発生している問題・エラーメッセージ
$ heroku run whenever --update-crontab Running whenever --update-crontab on ⬢ サービス名... up, run.4726 (Free) Traceback (most recent call last): 6: from /app/vendor/bundle/bin/whenever:29:in `<main>' 5: from /app/vendor/bundle/bin/whenever:29:in `load' 4: from /app/vendor/bundle/ruby/2.6.0/gems/whenever-0.11.0/bin/whenever:44:in `<top (required)>' 3: from /app/vendor/bundle/ruby/2.6.0/gems/whenever-0.11.0/lib/whenever/command_line.rb:6:in `execute' 2: from /app/vendor/bundle/ruby/2.6.0/gems/whenever-0.11.0/lib/whenever/command_line.rb:38:in `run' 1: from /app/vendor/bundle/ruby/2.6.0/gems/whenever-0.11.0/lib/whenever/command_line.rb:77:in `write_crontab' /app/vendor/bundle/ruby/2.6.0/gems/whenever-0.11.0/lib/whenever/command_line.rb:77:in `popen': No such file or directory - crontab (Errno::ENOENT)
該当のソースコード
ruby
1#schedule.rb 2 3every 1.day, :at => '3:00 am' do 4 rake "check_expired_coupons:check_coupons" 5 rake "check_expired_coupons:check_expired_coupons" 6end
ruby
1#application.rb 2 3module サービス名 4 class Application < Rails::Application 5 6 # taskパスのオートロード 7 config.autoload_paths += Dir["#{config.root}/lib/**/"] 8 config.eager_load_paths += Dir["#{config.root}/lib/**/"] 9 end 10end
試したこと
● (Errno::ENOENT)だったので、
$ heroku run bash Running bash on ⬢ サービス名... up, run.1794 (Free) ~ $ cd tmp ~/tmp $ cd cache ~/tmp/cache $ rm bootsnap-load-path-cache ~/tmp/cache $ rm -rf bootsnap-compile-cache
してみたのですが、効果なく
● rake "check_expired_coupons:check_coupons"
これ自体は実行できます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。