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

CRON cannot access my database? Could not find table. #844

Open
jcsii98 opened this issue Aug 25, 2023 · 1 comment
Open

CRON cannot access my database? Could not find table. #844

jcsii98 opened this issue Aug 25, 2023 · 1 comment

Comments

@jcsii98
Copy link

jcsii98 commented Aug 25, 2023

I am trying to run a model method in my cron job with whenever.

schedule.rb : `env :PATH, ENV['PATH']

set :output, "./cron.log"

every 1.minute do
runner "Stock.fetch_and_update_stock_data"
end`

the model method runs perfectly fine in rails console however putting it through CRON with whenever returns the error:
cron.log : bundler: failed to load command: bin/rails (bin/rails) /home/jcsii98/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.6/lib/active_record/connection_adapters/sqlite3_adapter.rb:387:in table_structure': Could not find table 'stocks' (ActiveRecord::StatementInvalid)`

Any suggestions?

@nbnp11
Copy link

nbnp11 commented Mar 20, 2024

try to add ENV.each { |k, v| env(k, v) } to your schedule.rb (that helped me)

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

2 participants