teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

zshを使用しているので明記

2020/03/30 00:08

投稿

launingcat
launingcat

スコア10

title CHANGED
File without changes
body CHANGED
@@ -5,6 +5,7 @@
5
5
  ・ruby : 2.6.5p114
6
6
  ・rails : 5.1.7
7
7
  ・bundler : 2.1.4
8
+ ・zsh
8
9
 
9
10
  wheneverとcronを使用した際に定期実行はされているが、下記エラーの為正しく処理ができず詰まっております。
10
11
  下記エラーの解消方法や関連エラーについて知見ございましたらご教示いただきたいです。

1

crontabとwheneverの設定内容を追記しました

2020/03/30 00:08

投稿

launingcat
launingcat

スコア10

title CHANGED
File without changes
body CHANGED
@@ -37,6 +37,52 @@
37
37
  2.1.4
38
38
  ```
39
39
 
40
+ #追記事項
41
+ ```
42
+ #crontab -l
43
+ SHELL=/usr/local/bin/zsh
44
+
45
+ # Begin Whenever generated tasks for: /Users/my_name/develop/app_name/config/schedule.rb at: 2020-03-30 07:49:19 +0900
46
+ PATH=/Users/my_name/develop/app_name/vendor/bundle/ruby/2.6.0/bin:/Users/my_name/.rbenv/versions/2.6.5/bin:/usr/local/Cellar/rbenv/1.1.2/libexec:/Users/my_name/.rbenv/shims:/usr/local/opt/libxml2/bin:/usr/local/bin:/Users/my_name/.pyenv/shims:/Users/my_name/.zplug/bin:/usr/bin:/bin:/usr/sbin:/sbin
47
+
48
+ * * * * * source $HOME/.zshrc; $(which zsh) -l -c 'cd /Users/my_name/develop/app_name && RAILS_ENV=development bundle exec rake tweet:text --silent >> /Users/my_name/develop/app_name/log/cron.log 2>&1'
49
+
50
+ # End Whenever generated tasks for: /Users/my_name/develop/app_name/config/schedule.rb at: 2020-03-30 07:49:19 +0900
51
+ ```
52
+
53
+ ```ruby
54
+ #/config/schedule.rb
55
+
56
+ require File.expand_path(File.dirname(__FILE__) + "/environment")
57
+
58
+ set :environment, Rails.env.to_sym
59
+ env :PATH, ENV['PATH']
60
+ set :output, "#{Rails.root.to_s}/log/cron.log"
61
+ set :job_template, "source $HOME/.zshrc; $(which zsh) -l -c ':job'"
62
+ job_type :runner, "cd :path && bundle exec rails runner -e :environment ':task' :output"
63
+
64
+ every 1.minute do
65
+ rake "tweet:text"
66
+ end
67
+
68
+ ```
69
+
70
+
71
+ ```ruby
72
+ #/tasks/tweet.rake
73
+ namespace :tweet do
74
+
75
+ desc "テスト..."
76
+ task :text => :environment do
77
+ logger = Logger.new 'log/test.log'
78
+ p "ここまでOK"
79
+ end
80
+
81
+ end
82
+ ```
83
+
84
+
85
+
40
86
  ### 試したこと
41
87
  gem install bundler:2.1.4
42
88
  bundle update --bundler