如何让'每当'宝石在Windows上工作? [英] How to make 'whenever' gem work on Windows?
问题描述
gem install时都会安装
,然后运行我的cron.rb require'rubygems'
require'when'
every 1.days,:at => '5:30 am'do
commandputs now
end
但是它抱怨说:
您的应用程序中没有安装i18n。
请将它添加到你的Gemfile并运行bundle install
所以我跑了 gem install i18n
现在相同的代码给我一个错误
C:\ ;红宝石cron.rb
cron.rb:4:未定义的方法 '每一个' 主:对象(NoMethodError)
任何想法我可以在宝石何时工作?
LOCAL GEMS
aaronh-chronic(0.3.9)
activesupport(3.0.9)
backports(1.18.2)
守护进程(1.1.0)
delayed_job(2.0。 3)
eventmachine(0.12.10 x86-mswin32-60)
fastercsv(1.5.4)
haml(3.0.21)
i18n(0.6.0)
json(1.5.1)
mechanize(1.0.0)
monkey-lib(0.5.4)
nokogiri(1.5.0 x86-mingw32,1.4.3.1 x86-mingw32)
rack(1.2.1)
rdiscount(1.6.8)
ruby-growl(3.0)
sinatra(1.2.6,1.0)
sinatra-advanced-routes (0.5.1)
sinatra-reloader(0.5.0)
sinatra-sugar(0.5.1,0.5.0)
thin(1.2.7 x86-mswin32)
倾斜(1.3)
每当(0.6.8)
这个gem是* nix工具 cron
的包装。我们可以将宝石源文件 command_line.rb 一中看到的>第75行,它使用'crontab'shell命令。
它不适用于标准Windows安装,因为此命令不可用。 b
有Windows版本,例如 cronw ,但我不能说这些是否会与任何宝石兼容。
或者,您可以将长时间运行的任务作为Windows服务运行。 这篇文章应该让你开始。
如果您必须使用when / cron,可能是因为您正在部署在* nix上,请尝试下载 Binami Rubystack虚拟机 - 你将在几分钟内启动并运行。
I wan to run "simple" cron using whenever on Windows XP. So I installed whenever gem install whenever
and then ran my cron.rb
require 'rubygems'
require 'whenever'
every 1.days, :at => '5:30am' do
command "puts now"
end
but it complained that
You don't have i18n installed in your application.
Please add it to your Gemfile and run bundle install
So I ran gem install i18n
and now the same code gives me an error
C:\whenever>ruby cron.rb
cron.rb:4: undefined method 'every' for main:Object (NoMethodError)
Any idea how I can make whenever gem work?
- ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
- gem 1.3.7
LOCAL GEMS
aaronh-chronic (0.3.9)
activesupport (3.0.9)
backports (1.18.2)
daemons (1.1.0)
delayed_job (2.0.3)
eventmachine (0.12.10 x86-mswin32-60)
fastercsv (1.5.4)
haml (3.0.21)
i18n (0.6.0)
json (1.5.1)
mechanize (1.0.0)
monkey-lib (0.5.4)
nokogiri (1.5.0 x86-mingw32, 1.4.3.1 x86-mingw32)
rack (1.2.1)
rdiscount (1.6.8)
ruby-growl (3.0)
sinatra (1.2.6, 1.0)
sinatra-advanced-routes (0.5.1)
sinatra-reloader (0.5.0)
sinatra-sugar (0.5.1, 0.5.0)
thin (1.2.7 x86-mswin32)
tilt (1.3)
whenever (0.6.8)
This gem is a wrapper for the *nix utility cron
. We can see in the gem source file command_line.rb line 75 that it uses 'crontab' shell command.
It will not work on a standard Windows install as this command is not available.
There are windows versions such as cronw, but I cannot say if these would be compatible with the whenever gem.
Alternatively you could run your long running task as a windows service. This article should get you started.
If you must use whenever/cron, perhaps because you are deploying on *nix, try downloading the Binami Rubystack VM - you'll be up and running in minutes.
这篇关于如何让'每当'宝石在Windows上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!