javan / javan/whenever

Crontab doesn't work with Rails 7

Open
#848 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
8.9k
Forks
715
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with config/schedule.rb and app/models/article.rb, then reproduce the whenever --update-crontab command using the listed Ruby and Rails versions. Check the generated cron entry and its log output; done means the scheduled runner executes every two minutes and updates Article content.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.