Whenever - Cron not working? Access is denied

"I installed cron with wehenever, but it doesn’t work. I tried to run the command manually and I got the error /bin/bash: bin/rails: Permission denied .

Here is what the cron command looks like:

/bin/bash -l -c 'cd /var/www/domain.net/main && bin/rails runner -e production '\''User.weekly_update'\'''

I also tried to run this command as root , but received the same message.

+6
source share
3 answers

Try bin / rails:

 chmod u+x bin/rails 

This, of course, assumes bin / rails is owned by crontab.

+6
source

I found that using RVM can complicate this. A decent alternative is to do your job in a rake job instead of a runner job:

 every 7.days do rake "user:weekly_update" end 

This, of course, requires additional code in the lib / tasks directory:

 namespace :user do task :weekly_update=> :environment do User.weekly_update end end 
+2
source

i had the same problem and solved it as follows:

(iam works with rvm, and my * / bin / rails already have + rx privileges)

As you can see in when-github , you can change job_type in config / schedule.rb

 job_type :runner, "cd :path && /other-path/path-x/bin/rails runner -e :environment ':task' :output" 
0
source

Source: https://habr.com/ru/post/956304/


All Articles