[英]Rails, using whenever gem in development
对不起快速问题来自相关的Rails新手。 我正在尝试使用Whenever gem来安排一些rake任务。 我不能为我的生活让它真正开始在我的开发机器上运行cron作业。
从其他stackoverflow线程来看,似乎我应该添加:
set :environment, "development"
到我的schedule.rb文件。 但那又怎样?
然后,一旦他们开始,我该如何停止cron工作?
在OSX中使用Rails 3.2.3
更新:答案是运行$ whenever -w
将cron作业写入crontab文件。 然后系统立即开始自动运行该crontab文件。
不幸的是,我的日志文件只包含以下内容: "rake aborted! Don't know how to build task <task name>"
我想这可能是由于已知的crontab / rvm问题,但欢迎任何建议。
清除现有的cron作业。
crontab -r
用环境更新cronjob。
whenever --update-crontab --set environment='development'
您可以使用whenever
命令及其各种选项来操作crontab。
$ whenever --help
Usage: whenever [options]
-i [identifier], Default: full path to schedule.rb file
--update-crontab
-w, --write-crontab [identifier] Default: full path to schedule.rb file
-c, --clear-crontab [identifier]
-s, --set [variables] Example: --set 'environment=staging&path=/my/sweet/path'
-f, --load-file [schedule file] Default: config/schedule.rb
-u, --user [user] Default: current user
-k, --cut [lines] Cut lines from the top of the cronfile
-v, --version
whenever -c cron-name #removing cronjobs
在config / schedule.rb之上添加以下代码行为我工作。
ENV['RAILS_ENV'] = "development"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.