Rails,在开发中随时使用 gem [英] Rails, using whenever gem in development

查看:36
本文介绍了Rails,在开发中随时使用 gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抱歉,来自一个相对的 Rails 新手的问题.我正在尝试使用 Whenever gem 来安排一些 rake 任务.我终其一生都无法真正开始在我的开发机器上运行 cron 作业.

Sorry quick question here from a relative Rails newbie. I'm trying to use the Whenever gem to schedule a number of rake tasks. I can't for the life of me get it to actually begin running the cron jobs on my development machine.

从其他 stackoverflow 线程来看,看来我应该添加:

Judging from other stackoverflow threads, it appears I should add this:

set :environment, "development"

到我的 schedule.rb 文件.但是然后呢?

to my schedule.rb file. But then what?

然后如何在启动后停止 cron 作业?

And then how do I stop the cron jobs once they've started?

在 OSX 中使用 Rails 3.2.3

Using Rails 3.2.3 in OSX

更新:答案是运行 $ 每当 -w 将 cron 作业写入 crontab 文件.然后系统会立即开始自动运行该 crontab 文件.

UPDATE: the answer is to run $ whenever -w which writes the cron job to a crontab file. The system then immediately starts running that crontab file automatically.

不幸的是,我的任何时候的日志文件都包含以下内容:"rake aborted!不知道如何构建任务<任务名称>"

Unfortunately, my logfile for whenever contains the following: "rake aborted! Don't know how to build task <task name>"

我认为这可能是由于已知的 crontab/rvm 问题,但欢迎提出任何建议.

I'm thinking this might be due to the known crontab/rvm issue, but any suggestions are welcome.

推荐答案

清除现有的 cron 作业.

Clear existing cron jobs.

crontab -r

使用环境更新 cronjob.

Update cronjob with the environment.

whenever --update-crontab --set environment='development'

这篇关于Rails,在开发中随时使用 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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