I do this all the time. Since this is your first time, maybe an example
will help:
cd /var/log
grep -i error messages |mail -s "message log errors" [EMAIL PROTECTED]
The results of the grep command are piped over to the mail command.
In the mail command the "-s" indicates the subject of the mail.
The mail is sent to [EMAIL PROTECTED], and is sent from whoever the local
user happens to be.
You can send to multiple addresses:
echo "Hi" |mail -s "test" -c [EMAIL PROTECTED] [EMAIL PROTECTED],[EMAIL PROTECTED]
This tiny message goes out with the subject "test" and is sent to:
[EMAIL PROTECTED] and [EMAIL PROTECTED] The message is also cc'ed to
[EMAIL PROTECTED]
I do this sort of thing all the time. Here is a standard program that I
run hourly on most servers... it's a simple volume and inode size test:
MSG=`df -ah |grep 9[56789]%`
if [ ! "xxx" == "xxx$MSG" ]; then
echo $MSG |mail -s "Volume Space Low on Server: GDM1" [EMAIL PROTECTED]
fi
#
MSG=`df -iah |grep 9[56789]%`
if [ ! "xxx" == "xxx$MSG" ]; then
echo $MSG |mail -s "Inode problem on Server: GDM1" [EMAIL PROTECTED]
fi
Take care - Jon Carnes
On Fri, 2003-06-20 at 15:55, Sean Murphy wrote:
> On Fri, 2003-06-20 at 15:52, Ryan Leathers wrote:
> > I would like to send emails based on events in logs and so on.
> > I have no trouble selecting events in an automated way.
> > I bet I can also format text to conform to some convention.
> >
> > This needs to be unattended - automatic - magic.
> > What is a simple way to send this email without writing code?
> > What do non-programmers use to solve this kind of thing?
> > Telnet to port 25 of some mail server?
>
> What about the mail command? Set it up as a cron job.
_______________________________________________
TriLUG mailing list
http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ:
http://www.trilug.org/faq/TriLUG-faq.html