現在railsアプリをawsにデプロイして動作の確認をしています。
gem 'whenever'
を使って1時間ごとにデータベースをリセット、初期化する設定をしたつもりですが
- MySQLで追加したデータが削除されていない
ためwheneverの設定がうまく言っていないことが確認されます。
aws-cli上でbundle exec crontab -e
コマンドを実行するとタスクは作られているのですがうまくいかない原因が分かりません(m_ m)
わかる方がいらっしゃれば教えていただきますようよろしくお願いいたします(m _m)
###エラー内容
whenever
でcron
に登録したはずのタスクが実行されていない
###期待する動作
- wheneverに登録した処理が毎時実行されるようにしたい
###動作環境
OS:mac
Ruby:2.3.5
Ruby on Rails: 4.2.5
MySQL: 5.7.18
whenever (0.10.0)
###参考サイト
###試したこと
aws-cli上で
bash
1# 1. アプリの階層へ移動 2cd /var/www/rails/myapp 3 4# 2. whenever設定用コマンドの実行 5bundle exec wheneverize . 6[skip] ./config/schedule.rb already exists 7[done] wheneverized! 8 9# 3. 下記の「該当ソースコード」のapp/config/schedule.rb を設定、保存 10# 4. 設定の確認 11bundle exec whenever 120 * * * * /bin/bash -l -c 'cd /var/www/rails/myapp && RAILS_ENV=production bundle exec rake db:migrate:reset --silent >> log/crontab.log 2>&1' 13 140 * * * * /bin/bash -l -c 'cd /var/www/rails/myapp && RAILS_ENV=production bundle exec rake db:seed --silent >> log/crontab.log 2>&1' 15 16# 5. cronにデータを反映 17bundle exec whenever --update-crontab
###該当のソースコード
Gemfile.rb
ruby
1gem 'whenever', require: false
app/config/schedule.rb
ruby
1require File.expand_path(File.dirname(__FILE__) + "/environment") 2set :output, 'log/crontab.log' 3set :environment, :production 4env :PATH, ENV['PATH'] 5 6every 1.hours do 7 rake 'db:migrate:reset' 8 rake 'db:seed' 9end 10 11#every 1.day, at:'10:30 am' do 12# rake 'db:migrate:reset RAILS_ENV=production' 13# rake 'db:seed RAILS_ENV=production' 14#end
あなたの回答
tips
プレビュー