【发布时间】:2016-05-25 23:18:57
【问题描述】:
我正在使用 ide cloud 9 导轨 5
我每次都安装 gem。
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 是空的。有没有我没有做的步骤?
【问题讨论】:
-
请从您的项目根目录运行
whenever命令。它会在 crontab 中显示您定义的任务吗?
标签: ruby-on-rails cron cloud9-ide