Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crontab doesn't work with Rails 7 #848

Open
danhbuidcn opened this issue Dec 28, 2023 · 2 comments
Open

Crontab doesn't work with Rails 7 #848

danhbuidcn opened this issue Dec 28, 2023 · 2 comments

Comments

@danhbuidcn
Copy link

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
@FiloSpaTeam
Copy link

I tried with a fresh Rails 7 installation.

ruby 3.2.1
rails 7.1.2

steps:

  1. rails new test
  2. add wheneverize gem
  3. add schedule with
every 2.minutes do
  runner 'puts "Working"'
end
  1. run bundle exec whenever --update-crontab

The local crontab is edited. What's not working?

@nbnp11
Copy link

nbnp11 commented Mar 20, 2024

  1. check if cron is running
  2. add ENV.each { |k, v| env(k, v) } to beginning of schedule.rb
  3. add output to your schedule set :output, 'log/cron.log'
  4. try to debug log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants