Whenever - Cron not working? Permission denied

前端 未结 3 862
半阙折子戏
半阙折子戏 2021-01-05 11:23

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

相关标签:
3条回答
  • 2021-01-05 11:49

    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
    
    0 讨论(0)
  • 2021-01-05 11:55

    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"
    
    0 讨论(0)
  • 2021-01-05 11:58

    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.

    0 讨论(0)
提交回复
热议问题