问题描述
我使用 gem与rails 3.在我的生产服务器(ubuntu)上,任务不运行。我尝试设置:set job_template
以获取。然而,这不解决问题。
这个特殊的生产ubuntu的问题是ruby路径不在 echo $ PATH
:
echo $ PATH
/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games
而ruby路径是/ var /因此,如果我手动编辑crontab文件并添加 PATH = / var / rails,我们可以使用下面的代码:rails / myapp / shared / bundle / ruby / 1.8 / bin
/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:游戏到crontab文件,转轮任务正确执行。
但是每次我做一个部署,我需要手动编辑crontab文件以添加PATH语句。
每当在crontab文件中添加此PATH行时,是否有任何方法,以便在每次部署后都不需要手动执行此操作?
感谢
我没有使用RVM并在文件中添加以下代码config / schedule.rb宝石相关代码)为我工作。
env:PATH,ENV ['PATH']
I am using whenever gem with rails 3. On my production server (ubuntu) , the runner task does not run. I tried setting the :set job_template
to get -l -i
as mentioned in this github ticket. However that does not solve the problem.
The problem on this particular production ubuntu is that the ruby path is not there in echo $PATH
:
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Whereas the ruby path is /var/rails/myapp/shared/bundle/ruby/1.8/bin
So if I manually edit the crontab file and add PATH=/var/rails/myapp/shared/bundle/ruby/1.8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
to the crontab file, the runner task is executed correctly.
However every time I do a deploy, I need to manually edit the crontab file to add the PATH statement to it.
Is there any way in whenever to add this PATH line in crontab file, so that there would not be any need to do this manually after every deploy?
Thanks
I am not using RVM and adding the below code in the file config/schedule.rb(place where u write whenever gem related code) worked for me.
env :PATH, ENV['PATH']
这篇关于每当PATH在crontab文件中为rails 3 ubuntu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!