Thinh Huynh
Thinh Huynh

Reputation: 81

Rails Whenever gem run only one time

I am using Whenever gem to setup a schedule. I added Whenever to gemfile and created schedule.rb file with code as below:

every 1.minute do
  p "testing ......................" 
end

I run the command whenever and the message testing ...................... appears only once.

I need to put the message once per minute. How can i do that?

Upvotes: 0

Views: 750

Answers (2)

ARaushan
ARaushan

Reputation: 16

Set environment variable as true and check true condition for that variable under scheduler.rb,make it false after first run.

Hope this will work for you !

Upvotes: 0

dp7
dp7

Reputation: 6749

Add this to top of your schedule.rb which basically creates a log file in your_app_path/log/cron_log.log

set :output, "log/cron_log.log"

You can check the log file to monitor the cron job output.

Hope it helps!

Upvotes: 1

Related Questions