2011-07-21 95 views
1

我希望在Windows XP上使用“简单”cron。所以我安装每当gem install whenever然后跑到我cron.rb如何让'每当'宝石在Windows上工作?

require 'rubygems' 
require 'whenever' 
every 1.days, :at => '5:30am' do 
    command "puts now" 
end 

但抱怨

You don't have i18n installed in your application. 
Please add it to your Gemfile and run bundle install 

于是我就gem install i18n现在同样的代码给我一个错误

C:\whenever>ruby cron.rb 
cron.rb:4: undefined method 'every' for main:Object (NoMethodError) 

任何想法如何我可以让宝石工作?

  • 红宝石1.8.7(2010-08-16 PATCHLEVEL 302)[I386-的mingw32]
  • 宝石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) 
+0

谢谢@保罗。 – Radek

+0

我现在正在使用rufus gem http://rufus.rubyforge.org/rufus-scheduler/ – Radek

回答

5

此宝石是一个* nix实用程序包装器cron。我们可以在第75行的宝石源文件command_line.rb中看到它使用'crontab'shell命令。

由于此命令不可用,它无法在标准的Windows安装中使用。

有Windows版本,如cronw,但我不能说这些是否会与每当宝石兼容。

或者,您可以将长时间运行的任务作为Windows服务运行。 This article should get you started.

如果您必须使用when/cron,可能是因为您正在部署在* nix上,请尝试下载Binami Rubystack VM - 您将在几分钟内启动并运行。

+1

我不需要随时使用。我的生产环境是Windows。所以我需要像cron for Windows那样的红宝石。我想这会是一个很好的新问题。感谢您的帮助。 – Radek