Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whenever - Cron not working? Permission denied

'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.

like image 220
Philip Giuliani Avatar asked Oct 19 '13 08:10

Philip Giuliani


2 Answers

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.

like image 61
Alexander Kobelev Avatar answered Sep 24 '22 16:09

Alexander Kobelev


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
like image 22
JellicleCat Avatar answered Sep 22 '22 16:09

JellicleCat