2

I would like to use Whenever gem to run scheduled jobs in my RoR application. I run the bundle install and this is my schedule.rb:

every 1.minute do
   runner "Event.executeEvents"
end

My Event.executeEvents method is a simple log entry:

class Event < ActiveRecord::Base

  def executeEvents
    puts "executeEvents at [" + Time.now.inspect + "]"
  end
end

If I execute whenever in command line, I got this:

$ whenever                       
* * * * * /bin/bash -l -c 'cd C:/dev/yanpyapi && bin/rails runner -e production '\''Event.executeEvents'\'''

## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.

Nothing is executed.

What I´m missing?

Do I need to initilize it somehow? I have read some doc about capistrano and RVM, but I don´t know what is this for...

Rober
  • 5,868
  • 17
  • 58
  • 110
  • possible duplicate of http://stackoverflow.com/questions/7548730/cron-job-not-working-in-whenever-gem/13257752#13257752 – damoiser Oct 11 '14 at 10:16

2 Answers2

12

You will have to execute

whenever -i

to add the jobs to crontab

usha
  • 28,973
  • 5
  • 72
  • 93
  • I get this error when I do it: $ whenever -i [fail] Couldn't write crontab; try running `whenever' with no options to ensure your schedule file is valid. – Rober Dec 23 '13 at 20:12
  • 1
    Add note: I´m trying to run it in a Windows 7. Does it work? I think it will only work on Unix systems... – Rober Dec 23 '13 at 20:20
2

Also, #executeEvents is defined as an instance method.

In the schedule.rb file you are calling it as class method.

imuzz
  • 51
  • 4