1

I have written scheduler using "Whenever Gem", where I have 2 schedulers in my scheduler.rb file. I want to get the logs from the scheduled tasks, so I have set :output, "log/cron_log.log" in scheduler.rb. currently all the logs for all the schedulers are logged in my log file, Instead I want the output to be logged for only one scheduler and not for any other scheduler. How can I do this?

My scheduler.rb

    set :output, "log/cron_log.log"

   #donot set output log for this.
    every 6.hours do
      rake "sidekiq:restart"
    end

   #set output log only for this scheduler 
    every :day, :at => '01:00am' do
      rake 'prune_users:older_than_2months'
    end
joe
  • 217
  • 2
  • 10

1 Answers1

0

You can try

# donot set output log for this.
every 6.hours do
  rake "sidekiq:restart"
end

# set output log only for this scheduler 
every :day, :at => '01:00am' do
  rake 'prune_users:older_than_2months', :output => {:error => 'error.log', :standard => 'cron.log'}
end

Btw, you can refer at link: https://github.com/javan/whenever/wiki/Output-redirection-aka-logging-your-cron-jobs

Vincent Nguyen
  • 311
  • 3
  • 5