[Gllug] Crons and mail

Marcus Taylor marcus at fatbeehive.com
Wed Mar 4 17:26:29 UTC 2009


On Wed, March 4, 2009 15:40, Richard Jones wrote:
> On Wed, Mar 04, 2009 at 03:24:16PM +0000, william pink wrote:
>
 What I really want to do is send out a email
>> if theres a error, there is a bash script that runs a Ruby rake task so
>> I presume there is a
>> way of manipulating the output of that or perhaps log to a file that can
>> be tailed+grepped for any obvious error keywords (which doesn't sound
>> like a great solution).
>
> I was fairly sure that MAILTO doesn't send mail if the job is silent.
> So the solution would be to make the job only print stuff on error :-)

I assume you are looking for errors from the Ruby rake script?

I would edit the bash script to check for the errors from the Rake script
[either by parsing the output of checking the status of the exit variable]
- you can them just pass these on or create your own errors messages.

I would then echo these errors messages [if any] to stderr [ echo "$blah"
>&2 ] in the bash script.

Then in the cron line redirect stdout to >/dev/null and leave stderr alone.

This may not be possible with Ruby/rake scripts - TBH I have no idea what
a rake script/task consists of.

Cheers
Marcus

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list