开发者

How to make 'whenever' gem work on Windows?

开发者 https://www.devze.com 2023-03-22 06:54 出处:网络
I wan to run \"simple\" cron using whenever on Windows XP. So I installed whenever gem install whenever and then ran my cron.rb

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-开发者_StackOverflow中文版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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号