【问题标题】:Cron job not working for Whenever gem, rails 5Cron 工作不适用于每当 gem,rails 5
【发布时间】: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


【解决方案1】:

除非您使用 SSH 工作区,否则 Cron 作业无法在 Cloud9 上运行。


来源:How to enable/run cron on Cloud9?

【讨论】:

    猜你喜欢
    • 2015-02-28
    • 2011-11-24
    • 2016-03-01
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-20
    • 1970-01-01
    相关资源
    最近更新 更多