Skip to content

Crontab doesn't work with Rails 7 #848

@danhbuidcn

Description

@danhbuidcn

Crontab is not working.
I have configured crontab with the settings below.
I ran whenever --update-crontab, but it is not working.

ruby 3.1.4
rails 7.0.8

#config/schedule.rb

set :output, "/log/cron_log.log"

every 2.minutes do
  runner 'Article.update_content'
end

#app/models/article.rb

class Article < ApplicationRecord
  class << self
    def update_content
      article = Article.first
      content = article.content.to_i + 1
      article.update content: content
    end
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions