Rails5.1.3でWebアプリケーション制作の勉強をしています。
バッチ処理をしようとcronを使いたのですが以下のように記述しても読み込んで実行してくれないので
対処方法をどなたか教えていただけませんでしょうか?
設定内容は以下になりますが、このコードの記述がおかしいのかと思っていますのでご指摘いただければと思います。
config/application.rbに以下を追記しました。 config.autoload_paths += %W(#{config.root}/lib) config.enable_dependency_loading = true config.autoload_paths << Rails.root.join('lib')
config/schedule.rbの記述内容 set :output, 'log/crontab.log' ENV['RAILS_ENV'] ||= 'development' set :environment, ENV['RAILS_ENV'] set :environment, "development" every 1.day, at: '12pm' do runner "Yesterday.introduction" end every 1.day, at: '13:45pm' do runner "Series.introduction" end
以下を実行しました。 [vagrant@localhost chibi]$ bundle exec whenever 0 12 * * * /bin/bash -l -c 'cd /home/vagrant/chibi/chibi && bundle exec bin/rails runner -e development '\''Yesterday.introduction'\'' >> log/crontab.log 2>&1' 45 13 * * * /bin/bash -l -c 'cd /home/vagrant/chibi/chibi && bundle exec bin/rails runner -e development '\''Series.introduction'\'' >> log/crontab.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.
以下を実行しました。 [vagrant@localhost chibi]$ bundle exec whenever --update-crontab [write] crontab file updated
以下を実行しました。 [vagrant@localhost chibi]$ crontab -l # Begin Whenever generated tasks for: /home/vagrant/chibi/chibi/config/schedule.rb 0 12 * * * /bin/bash -l -c 'cd /home/vagrant/chibi/chibi && bundle exec bin/rails runner -e development '\''Yesterday.introduction'\'' >> log/crontab.log 2>&1' 45 13 * * * /bin/bash -l -c 'cd /home/vagrant/chibi/chibi && bundle exec bin/rails runner -e development '\''Series.introduction'\'' >> log/crontab.log 2>&1' # End Whenever generated tasks for: /home/vagrant/chibi/chibi/config/schedule.rb
runner Yesterday.introductionとrunner Series.introductionの動作確認はコンソール上で確認できております。
13:45にSeries.introductionを実行させたかったのですが実行されませんでした。
どこが悪さしているのか全くわからなくて困っています。
どなたか教えていただけないでしょうか?宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー