Whenever cronjobs doesn't run on staging - but works on production

262 views Asked by At

I am facing a very weird scenario.

I am using whenever to run cron jobs in the following way

every 1.day, at: '12:30 am' do
     runner 'CronJobs.some_method'
end

The error is logged to cron_error.log. Everytime I get this weird error in the log file

 unknown OID 705: failed to recognize type of 'user'. It will be treated as String.

However, the same cron works fine in the production environment.

I also tried running the method via rails runner and it works fine. Any help will be appreciated.

1

There are 1 answers

0
Satishakumar Awati On

When updating crotab pass environment mode of application

 whenever --update-crontab  myapp --set 'environment=stagging'

and in schedule.rb add this line

 ENV['RAILS_ENV'] = "#{@pre_set_variables[:environment]}"

I hope this helps you !!