#646·whenever

Cron Jobs stopped working... Not quite sure why

Author: DanGrenierCreated Jul 19, 2016Updated Nov 13, 2023
Labelsawaiting-feedbackruby-version-manager-messusage-question

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

ruby
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