質問編集履歴
2
zshを使用しているので明記
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
・rails : 5.1.7
|
12
12
|
|
13
13
|
・bundler : 2.1.4
|
14
|
+
|
15
|
+
・zsh
|
14
16
|
|
15
17
|
|
16
18
|
|
1
crontabとwheneverの設定内容を追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -76,6 +76,98 @@
|
|
76
76
|
|
77
77
|
|
78
78
|
|
79
|
+
#追記事項
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
#crontab -l
|
84
|
+
|
85
|
+
SHELL=/usr/local/bin/zsh
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
# Begin Whenever generated tasks for: /Users/my_name/develop/app_name/config/schedule.rb at: 2020-03-30 07:49:19 +0900
|
90
|
+
|
91
|
+
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
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
* * * * * 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'
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
# End Whenever generated tasks for: /Users/my_name/develop/app_name/config/schedule.rb at: 2020-03-30 07:49:19 +0900
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
|
107
|
+
#/config/schedule.rb
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
require File.expand_path(File.dirname(__FILE__) + "/environment")
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
set :environment, Rails.env.to_sym
|
116
|
+
|
117
|
+
env :PATH, ENV['PATH']
|
118
|
+
|
119
|
+
set :output, "#{Rails.root.to_s}/log/cron.log"
|
120
|
+
|
121
|
+
set :job_template, "source $HOME/.zshrc; $(which zsh) -l -c ':job'"
|
122
|
+
|
123
|
+
job_type :runner, "cd :path && bundle exec rails runner -e :environment ':task' :output"
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
every 1.minute do
|
128
|
+
|
129
|
+
rake "tweet:text"
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
|
143
|
+
#/tasks/tweet.rake
|
144
|
+
|
145
|
+
namespace :tweet do
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
desc "テスト..."
|
150
|
+
|
151
|
+
task :text => :environment do
|
152
|
+
|
153
|
+
logger = Logger.new 'log/test.log'
|
154
|
+
|
155
|
+
p "ここまでOK"
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
79
171
|
### 試したこと
|
80
172
|
|
81
173
|
gem install bundler:2.1.4
|