whenever icon indicating copy to clipboard operation
whenever copied to clipboard

Cron Jobs stopped working... Not quite sure why

Open DanGrenier opened this issue 8 years ago • 4 comments

Hello, i had been using the gem without issue for weeks but all the sudden the cron jobs stopped working. I knew right away because the jobs send emails upon completion. Nothing major has changed on the app so i am really unsure what could be the problem. I have tried to specify the PATH in my schedule.rb file as reported by other users with the same issues but it did not fix my problem.

This is what i have in my schedule.rb

every 5.minutes do
    runner "BankPaymentWorker.dated_transaction_reconciliation", :environment => 'development'
end

And this translates to the following when i pull a crontab - l

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /bin/bash -l -c 'cd /home/db1/reap && bundle exec bin/rails runner -e development '\''BankPaymentWorker.dated_transaction_reconciliation'\'' >> /home/db1/reap/cron_log.log 2>&1'

If i execute the following from the terminal it works fine: /bin/bash -l -c 'cd /home/db1/reap && bundle exec bin/rails runner -e development '\''BankPaymentWorker.dated_transaction_reconciliation'\'' >> /home/db1/reap/cron_log.log 2>&1

But when called from the cron job it does not work. The most irritating part is that i don't get a particular error message in my cron_log.log

I know the cron job uses a different environment and paths from the user that executes in the terminal but i can't seem to find a way to force the correct environment to the cron job.

One hint that things are different is what is a warning i am getting in the cron_log.log when the call is made from the Cron Job. (Not working)

/home/db1/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.8.4/lib/bundler/shared_helpers.rb:83: warning: Insecure world writable dir /home/db1/reap in PATH, mode 040777

Versus the same warning when the call is made from the terminal (Working)

/home/db1/reap/vendor/cache/ruby/2.2.0/gems/spring-1.7.1/lib/spring/application.rb:175: warning: Insecure world writable dir /home/db1/reap in PATH, mode 040777
Running via Spring preloader in process 8360

DanGrenier avatar Jul 19 '16 18:07 DanGrenier

Please explain:

  1. How you install Ruby
  2. Which user the crontab is written as, and which user you use to manually execute these commands
  3. How you deploy your application
  4. Dependency versions (Gemfile and Gemfile.lock)
  5. What changes, however insignificant you believe them to have been, that you made immediately before the cron jobs began to fail

benlangfeld avatar Jul 19 '16 18:07 benlangfeld

  1. I seem to have a mix of rvm and rbenv. I can't tell for sure
  2. Both the crontab creation and terminal execution were done with user db1
  3. Right now it's sitting on a development box running the basic rail server
source 'https://rubygems.org'

gem 'rails', '4.2.4'

gem 'pg'

gem 'bootstrap-sass','3.3.6'

gem 'font-awesome-sass','4.5.0'

gem 'sass-rails', '~> 5.0'

gem 'uglifier', '>= 1.3.0'

gem 'coffee-rails', '~> 4.1.0'

gem 'jquery-rails'

gem 'turbolinks'

gem 'jbuilder', '~> 2.0'

gem 'sdoc', '~> 0.4.0', group: :doc

gem 'seed_dump'

gem 'credit_card_icons'

gem 'chartkick'

gem 'thinreports'

gem 'holidays'

group :development, :test do
  gem 'byebug'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

gem 'devise' , '3.5.6'
gem 'gon'
gem 'savon', '2.11.0'
gem 'figaro'
gem 'redis', '~>3.2'
gem 'sidekiq'
gem 'sinatra', require: false
gem 'slim'
gem 'will_paginate', '~> 3.1.0'
gem 'whenever', :require => false

group :test do 
 gem 'faker'    
 gem 'capybara'
 gem 'database_cleaner'
 gem 'guard-rspec'
 gem 'launchy'
end
  1. I believe i installed thinreports, which is a gem to generate reports and save/download them as pdf

DanGrenier avatar Jul 19 '16 18:07 DanGrenier

I'd suggest you start by removing both rbenv and rvm, choosing one, and then installing it cleanly. I don't have time to help debug potential interactions between the two. If you still have issues with only one of them in play, I'd be happy to help you figure it out.

benlangfeld avatar Jul 19 '16 19:07 benlangfeld

I believe we can close this issue given that it has had no interaction in years and might be stale by now.

cc @benlangfeld

bragamat avatar Nov 13 '23 00:11 bragamat