jasdeepg
jasdeepg

Reputation: 177

Using whenever gem to schedule a cron job

I'm testing whenever to figure out how to use it and am running into trouble even after reading the Github documentation.

I simply want to update the attributes of my model like this (config/schedule.rb)

set :output "/log/today.log"

every 10.seconds do
  runner "Example.update_all(sample: Time.now)"
end

I am neither seeing a log file nor seeing the model attributes updated.

Is there anything I am not doing correctly?

Upvotes: 1

Views: 2181

Answers (1)

Heena Hussain
Heena Hussain

Reputation: 3691

First you need to add your cron job in the cron tab. If you do not want to add because you are just testing it, you can try the code given below(which i did for my rails application).

cd /home/your_home/your_project && script/your_script -e <environment> "method_call"

In your case:

environment = development method_call = Example.update_all(sample: Time.now)

It might help you.

Upvotes: 2

Related Questions