Cron +每当不与RVM一起使用时 [英] Cron + whenever not working with RVM

查看:89
本文介绍了Cron +每当不与RVM一起使用时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RVM环境。 RUby版本:2.1.2导轨:4.1.1

  schedule.rb:

每1。分钟做
赛跑者 note.send_mail
结束

我使用了每当--update-crontab 来更新cron标签。



当我使用检查作业时crontab -l <​​/ code>它显示如下,没有设置适当的时间。
和cron作业不起作用。

  * * * * * / bin / bash -l -c' cd /桌面/文件夹1 /博客2&& bin / railsrunner -e生产'\''note.send_mail'\'''

有人可以帮我解决这个问题吗?谢谢!

解决方案

转到您的〜/ .rvmrc 文件并添加以下内容:

  rvm_trust_rvmrcs_flag = 1 

然后在 --update-crontab 时再次输入。根据任何时候的自述文件


如果您的生产环境使用RVM(Ruby版本管理器),则会遇到一个陷阱,导致cron作业挂起。这与everyever不直接相关,并且调试起来很棘手。您的.rvmrc文件必须受信任,否则cron作业将挂起,等待文件受信任。一种解决方案是禁用提示,方法是将该行添加到〜/ .rvmrc中的用户rvm文件中。

rvm_trust_rvmrcs_flag = 1


信任所有rvmrc文件。


如果这对您不起作用,请尝试此页面中提及的其他解决方案: RVM-Notes


I am using RVM environment. RUby version : 2.1.2 rails : 4.1.1

schedule.rb : 

    every 1.minute do 
    runner "note.send_mail" 
    end 

I used whenever --update-crontab to update the cron tab.

when I check the jobs using crontab -l it shows up as below with no proper time set up. and the cron job does not work.

 * * * * * /bin/bash -l -c 'cd /Desktop/folder1/blog2 && bin/rails runner -e production '\''note.send_mail'\''' 

Can some one help me out fix this. Thanks!

解决方案

Go to your ~/.rvmrc file and add the following:

rvm_trust_rvmrcs_flag=1

Then whenever --update-crontab again. According to the README of whenever:

If your production environment uses RVM (Ruby Version Manager) you will run into a gotcha that causes your cron jobs to hang. This is not directly related to Whenever, and can be tricky to debug. Your .rvmrc files must be trusted or else the cron jobs will hang waiting for the file to be trusted. A solution is to disable the prompt by adding this line to your user rvm file in ~/.rvmrc

rvm_trust_rvmrcs_flag=1

This tells rvm to trust all rvmrc files.

If that doesn't work for you, try other solutions mentioned in this page: RVM-Notes.

这篇关于Cron +每当不与RVM一起使用时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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