Cron Job notification email

Hi,

I'm fairly new to Aix and am looking for some help on the following.

I have setup a cron job under root and want it to send the email once it's run to an external email address. I can get it to send the output in an email to me by using mail on the end of the crontab entry. But I would like to get the email thats sent to root once the cronjob has run as displayed below sent to my external address.

/var/spool/mail/root

From daemon Mon Jan 12 15:59:01 2009
Received: (from daemon@localhost)
by (AIX5.3/8.13.4/8.11.0) id n0CFx1eq1044526
for root; Mon, 12 Jan 2009 15:59:01 GMT
Date: Mon, 12 Jan 2009 15:59:01 GMT
From: daemon
Message-Id: <200901121559.n0CFx1eq1044526@
To: root
Subject: Output from cron job su - db2inst1 -c /database/db2inst/sqllib/db2dump/scripts/matt , root@, exit statu s 0
Cron Environment:
SHELL =
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java14/jre/bin:/usr/java14/bin
CRONDIR=/var/spool/cron/crontabs
ATDIR=/var/spool/cron/atjobs
LOGNAME=root
HOME=/
Your "cron" job executed on Mon Jan 12 15:59:00 GMT 2009
su - db2inst -c /database/db2inst/sqllib/db2dump/scripts/matt

produced the following output:

Thanks in advance.

Matt.

cronjobs should be designed to create no output, an if they create no output no mail is created

your way with sending the output with a mail command in the job is the preferred way

other way:
generate a user cron

install sudo if not already installed

all cron jobs which should send to your email-address must be run from the new users crontab, running commands with sudo/sticky bit

specify a mail alias in /etc/sendmail/aliases for the new user

newuser:youremail@domain

#sendmail -bi

sendmail must run

#startsrc -s sendmail

perhaps there is an easier way :wink: