我正在使用ide cloud 9 Rails 5
无论何时,我都会安装宝石。
gem 'whenever', :require => false
schedule.rb:
set :output, "#{path}/log/cron.log"
every 2.minutes do
rake "subscription:send_mails"
end
namespace :subscription do
desc "Send dayly mails with new projects"
task send_mails: :environment do
Subscriber.where.not(categories: []).find_each do |subscriber|
projects = Project.where(categories: subscriber.categories, created_at: 1.days.ago )
SubscriptionMailer.send_email_with_new_projects(subscriber, projects).delivery_now
end
end
end
在命令行中运行:
bundle exec whenever
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /bin/bash -l -c 'cd /home/ubuntu/workspace && RAILS_ENV=production bundle exec rake subscription:send_mails --silent >> /home/ubuntu/workspace/log/cron.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.
现在以开发模式运行本地服务器。我没有看到任何证据表明代码实际上正在运行。 log / cron.log为空。我有没有采取一些措施?