RVM无法使用cron设置环境 [英] RVM isnt setting environment with cron

查看:131
本文介绍了RVM无法使用cron设置环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个粗略的时间执行脚本/转轮与cron和RVM。我相信问题在于rvm环境未被设置之前运行器被执行。



目前会抛出错误
/ bin / sh:1.sql:command not found
这是我之前得到的,所以我猜这很好。



我读过这个线程,但是我仍然没有真正得到它。部分问题我认为是错误报告。



这是我的赛跑者迄今为止。

  * / 1 * * * * * / bin / bash -l -c'rvm use 1.8.7-p352@2310; cd development / app / my_app2310&& script / runner -e developmentMailer.find_customer'

a rvm_cron_runner。



我创建了一个文件并将其放置在其中:

 #!/ bin / sh 
source/Users/dude/.rvm/scripts/rvm
exec $ 1

然后我更新我的crontab到这。

  * / 1 * * * * * / bin / bash -l -c'/ Users / dude / development / app / my_app2310 / rvm_cron_runner; rvm使用1.8.7-p352@2310; cd development / app / my_app2310&& script / runner -e developmentMailer.find_customer'

这也没有什么区别。我得到没有错误。没有。



任何人都能看到我做错了什么?



我希望我的代码格式化工作。

解决方案

您可以尝试将要运行的代码放在单独的脚本中,然后使用 rvm_cron_runner



所以将你的操作放在一个名为 / path / cron_job

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

然后在crontab中写

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

差异:




  • 这不会启动单独的shell

  • 使用 rvm_cron_runner
  • 的参数


使用 .rvmrc 文件,你甚至可以删除 rvm use ... >

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.

currently im throwing the error /bin/sh: 1.sql: command not found which is more than i've gotten earlier, so i guess that's good.

I've read this thread Need to set up rvm environment prior to every cron job but im still not really getting it. Part of the problem i think is the error reporting.

this is my runner thus far.

 */1 * * * * * /bin/bash -l -c 'rvm use 1.8.7-p352@2310; cd development/app/my_app2310 && script/runner -e development "Mailer.find_customer"'

as per the above link, i tried making a rvm_cron_runner.

i created a file and placed this in it:

#!/bin/sh
source "/Users/dude/.rvm/scripts/rvm"
exec $1

then i updated my crontab to this.

*/1 * * * * * /bin/bash -l -c '/Users/dude/development/app/my_app2310/rvm_cron_runner; rvm use 1.8.7-p352@2310; cd development/app/my_app2310 && script/runner -e development "Mailer.find_customer"'

This also has made no difference. i get no error. nothing.

Can anyone see what i'm doing incorrectly?

P.S i hope my code formatting worked.

解决方案

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.

这篇关于RVM无法使用cron设置环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆