I tried to find a solution for having email sent with whenever when
something written if stderr; but without success (I'm using rake
jobtype).
Why rake jobtype adds "2>&1" at the end of the generated crontab
lines ? This prevents cron from getting the stderr outputs and send it
by email; so the MAILTO becomes useless.
A primary solution for that could be a syntax like :
* * * * * (cd /var/rails/my_app && RAILS_ENV=production /usr/bin/env
rake test >> /var/rails/my_app/log/cron.log) | tee /var/rails/my_app/
log/cron_errors.log
The use of tee command allow the catching of std_err and email sending
by cron.
I suppose that an other way would be to define a new job_type;
something like
job_type :rake_with_error_mail, "(cd #{RAILS_ROOT} && /usr/bin/env
rake utils:test >> #{RAILS_ROOT}/log/cron.log) | tee #{RAILS_ROOT}/log/
cron_errors.log"
or something like that.
But I've an error after upgrading from 0.4.1 to 0.5.2 :
/home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/lib/whenever/job_list.rb:
24:in `initialize': /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/
activesupport-2.3.5/lib/active_support/dependencies.rb:105:in
`const_missing': uninitialized constant Whenever::JobList::RAILS_ROOT
(NameError)
from (eval):8:in `initialize'
from /home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/lib/whenever/
base.rb:4:in `eval'
from /home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/lib/whenever/
job_list.rb:24:in `initialize'
from /home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/lib/whenever/
base.rb:4:in `new'
from /home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/lib/whenever/
base.rb:4:in `cron'
from /home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/lib/whenever/
command_line.rb:42:in `run'
from /home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/lib/whenever/
command_line.rb:8:in `execute'
from /home/bduye/.gem/ruby/1.8/gems/whenever-0.5.2/bin/whenever:35
from /opt/ruby-enterprise/bin/whenever:19:in `load'
from /opt/ruby-enterprise/bin/whenever:19
Why couldn't it be possible to use RAILS_ROOT constant inside
whenever ? Just opened a ticket for that :
http://github.com/javan/whenever/issues/issue/81