undefined method 'every'
-
14-11-2019 - |
Question
Trying to use the whenever ruby gem, however (no pun intended) errors occur every time something is run:
1.9.3-p0 :001 > require 'whenever'
=> true
1.9.3-p0 :002 > every 1.minutes do
1.9.3-p0 :003 > puts 'hi'
1.9.3-p0 :004?> end
NoMethodError: undefined method `every' for main:Object
from (irb):6
from /Users/rudolph9/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
I am running Mac OS 10.7.3
, Ruby 1.9.3
, and Whenever v0.7.3
. Is this a cron job issue with OSX? What exactly the issue?
Solution
The whenever gem is not meant to be called directly like that. The blocks that you want to execute go into a schedule file (config/schedule.rb
by default) that recognizes the DSL for cron-like tasks.
You can preview how your commands will be converted to the crontab by running the whenever
command within the directory. Then to commit the jobs to your crontab, use
whenever --write-crontab
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow