I'm trying to create a cron job that runs a controller method with the whenever gem but i'm having trouble.
config\schedule.rb
every 1.minutes do
runner "Reset.reset"
end
lib\reset.rb
class Reset
def reset
logger.debug("This is the cron job")
end
end
I also ran the whenever --update-crontab to update the cron job.
Why isn't the logger message showing up in the log?
Thanks for all the help.
That's because
Reset.resettrys to call the reset method on the Reset class. That is,Reset.resettrys to call a class method.Your reset method is an instance method. To define a
Reset.resetclass method, use:Also, you'll need to make sure that you have a
self.loggerclass method as well, or that code will just die.Lastly, for your own edification:
Resetas you have it written isn't a controller. It's just a plain old ruby object.