1

On server we have the following cronfile:

MAILTO=admin_email@project.com
* * * * * /bin/bash -l -c 'cd /path/to/project/folder;RAILS_ENV=production bundle exec rake some_rake_task'
0 */2 * * * /bin/bash -l -c 'cd /path/to/project/folder;RAILS_ENV=production bundle exec rake another_rake_task'
# and so on

I had no problems with moving it to whenever:

config/schedule.rb:

every '* * * * *' do
  rake 'some_rake_task', output: 'log/cron.log'
end
every '0 */2 * * *' do
  rake 'another_rake_task', output: 'log/cron.log'
end
# and so on

The question is how do I implement MAIL_TO option in whenever, so that when anything goes wrong admin is getting notified?

Thanks!

Community
  • 1
  • 1
Andrey Deineko
  • 51,333
  • 10
  • 112
  • 145

1 Answers1

0

If I were you, I would set up error notifications with Airbrake or Rollbar which can both be configured to notify of errors within Rake tasks. That way you'll get notified automatically when something goes wrong in your CRON jobs.

rlarcombe
  • 2,958
  • 1
  • 17
  • 22