RVM isnt setting environment with cron

后端 未结 3 659
青春惊慌失措
青春惊慌失措 2021-01-15 02:43

I\'m having a rough time executing script/runner with a cron and RVM. I believe the issues lie with the rvm environment not being set before the runner is executed.

3条回答
  •  死守一世寂寞
    2021-01-15 03:24

    Could you try to place the code you want to run in a separate script, and then use the rvm_cron_runner ?

    So place your actions in a file called /path/cron_job

    rvm use 1.8.7-p352@2310
    cd development/app/my_app2310 && script/runner -e development "Mailer.find_customer"
    

    and then in your crontab write

    1 2 * * * /path/rvm_cron_runner /path/cron_job
    

    The differences:

    • this does not start a separate shell
    • use the parameter of the rvm_cron_runner

    If you would use an .rvmrc file, you could even drop the rvm use ... line, I think.

提交回复
热议问题