SUMMARY cronjob output sent to different e-mail address

From: Duncan Vella (dvella@melitacable.com)
Date: Wed Oct 06 1999 - 10:51:51 CDT


WOW, it only took 10 mins to get about 3 solutions! Thanks.

QUERY:

I have a cronjob that has to be executed by root.
The process run does not produce an output except when there is
an error. The error output is then sent to root (the owner
of the cronjob)

I would like the error output of this particular process to be sent to
another e-mail address. Setting an alias of root to this e-mail
in /etc/aliases is not fine because the root mail is read by other
myself.

I tried to add " | mailx xxx@x.com" to the program but this still
sent the error to root and an empty message to xxx@x.com.

Anyone knows how to enable this.

SOLUTIONS (so far):

(1) Redirect output to file and send file to mail recipient.
(2) Give the userid permission to run a cron and execute job as root.
(3) BEST SOLUTION Redirect stderr to stout by adding 2>&1 as follows:
0 2 * * 0 /script/to/run 2>&1 | mailx -s "subject" xxx@x.com

Thanks to:

Akash X Dhama
Stan Francis
Mark Lundy
Thomas D. Knox
Danny Johnson
Tim Pointing
(and the rest who will respond.)

regards,
Ducan



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:13:26 CDT