How to Make 'Whenever' Gem Work on Windows

How to make 'whenever' gem work on Windows?

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.

Running whenever cron in Windows

Although it's nowhere near as flexible as cron, windows has the AT command which may be able to solve your problems, however you can only schedule it to run at most once a day. To see how to use AT run AT /? on your command line.

For much more fine-grained control over running tasks you can use the GUI based windows task scheduler. you can find this in Control Panel -> System and Security -> Administrative Tools -> Task Scheduler

The system cannot find the path specified, whenever gem

Given the directory paths showing in your error output it appears that you are running on Windows. The problem is that the whenever gem is a wrapper for the unix/linux command 'cron' which doesn't exist on Windows. See this answer for more details.

Whenever gem controller method not working

That's because Reset.reset trys to call the reset method on the Reset class. That is, Reset.reset trys to call a class method.

Your reset method is an instance method. To define a Reset.reset class method, use:

class Reset
def self.reset
logger.debug("This is the cron job")
end
end

Also, you'll need to make sure that you have a self.logger class method as well, or that code will just die.

Lastly, for your own edification: Reset as you have it written isn't a controller. It's just a plain old ruby object.

rails 4.2.0 with whenever gem in development env, not working

Using output in schedule help me to find a problem.

I used specific gemset and not specify it in my schedule.
That's why I got error. Whenever gem trying to use default gemset which was different from gemset that I use for my project.

So there are two options for solving problem, use default gemset or specify yours in schedule.

Sample of setting gemset and env:

set :environment, :development

Rake:

job_type :rake, "cd :path && $HOME/.rvm/scripts/rvm && rvm use
2.2.0@somename && rake ':task' :output"

Runner:

job_type :runner, "cd :path && $HOME/.rvm/scripts/rvm && rvm use 2.2.0@somename && bin/rails runner ':task' :output"



Related Topics



Leave a reply



Submit