Whenever - Cron not working? Permission denied
Asked Answered
N

3

6

'I have set up a cron with wehenever, but its not working. I tried to run the command manually and i get the error /bin/bash: bin/rails: Permission denied.

Here what the command of the cron 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 i got the same message.

Numeration answered 19/10, 2013 at 8:8 Comment(0)
K
6

Try to make bin/rails executable:

chmod u+x bin/rails

This is, of course, assuming that bin/rails is owned by the crontab's user.

Kolivas answered 19/10, 2013 at 10:11 Comment(0)
I
2

I found that use of RVM can complicate this. A worthy alternative is to make your whenever job into a rake job instead of a runner job:

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

This does, of course, necessitate an extra bit of code in your lib/tasks directory:

namespace :user do
  task :weekly_update=> :environment do
    User.weekly_update
  end
end
Imperious answered 6/2, 2014 at 16:54 Comment(0)
M
0

i had the same problem and solved this as follows:

(iam work with rvm and my */bin/rails has already +rx privileges)

As you can see in whenever-github you can change job_type within config/schedule.rb

job_type :runner,  "cd :path && /other-path/path-x/bin/rails runner -e :environment ':task' :output"
Mazel answered 1/12, 2016 at 23:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.