设置路径每当cron的,因此它可以找到红宝石 [英] Setting path for whenever in cron so it can find ruby
问题描述
我的红宝石是在/ usr / local / bin目录。 每当无法找到它,并在我的cron文件的顶部设置PATH也不管用,我想因为每当运行该命令新的bash实例内。
My ruby is in /usr/local/bin. whenever can't find it, and setting PATH at the top of my cron file doesn't work either, I think because whenever is running the command inside of a new bash instance.
# this does not work
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin
# Begin Whenever generated tasks for: foo
0 * * * * /bin/bash -l -c 'cd /srv/foo/releases/20110429110637 && script/rails runner -e production '\''ActiveRecord::SessionStore::Session.destroy_recent(15)'\'''
# End Whenever generated tasks for: foo
我如何知道无论何时何地我的红宝石二进制是什么?从/ usr / bin中制作一个符号链接似乎凌乱的我,但我想这可能是唯一的选择。
How can I tell whenever where my ruby binary is? Making a symbolic link from /usr/bin seems messy to me, but I guess that might be the only option.
<一个href=\"http://stackoverflow.com/questions/5698028/whenever-path-in-crontab-file-for-rails-3-ubuntu\">This 报价问题 ENV:PATH,...
在schedule.rb作为一个解决方案,但(一)我无法找到该功能的任何文件在文档中的任何地方(二)它似乎并没有已经解决了提问者的问题(不幸的是它需要不平凡的周转时间,我只是尝试)。
更新 在这个页面的底部,我会尝试吧。
This question offers env :PATH, "..."
in schedule.rb as a solution, but (a) I can't find any documentation of that feature anywhere in the docs (b) it doesn't seem to have solved the asker's problem (unfortunately it takes non-trivial turnaround time for me to just try it).
update actually it is in the bottom of this page, i'll try it now.
更多信息
- 我不能,因为它是由每当 生成修改cron命令
- 我核实,如果我与
的bash -l </ code>一个新的bash shell是/ usr / bin中/ env的发现红宝石就好了
- 我只是想在cron中的确切的命令,开始/斌/ bash中,从用户的命令行,它的工作。
- I can't modify the cron command because it's generated by whenever
- i verified that if I make a new bash shell with
bash -l
, /usr/bin/env finds ruby just fine - I just tried the exact command in cron, starting with /bin/bash, from the command line of that user, and it worked.
所以,这是非常神秘的...
so, this is very mysterious...
推荐答案
解决方案是把这个 schedule.rb
:
env :PATH, ENV['PATH']
这篇关于设置路径每当cron的,因此它可以找到红宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!