Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Oct 2009 17:19:37 +0000
From:      krad <kraduk@googlemail.com>
To:        "Daniel C. Dowse" <dcdowse@gmx.net>
Cc:        Kelly Martin <kellymartin@gmail.com>, FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: changing cron's From: address in emails
Message-ID:  <d36406630910251019g74ab55cclc4e829ec35b3cd35@mail.gmail.com>
In-Reply-To: <20091025021009.051de285.dcdowse@gmx.net>
References:  <1338880b0910240008h5d5e7846q8ccf184728d9e036@mail.gmail.com> <20091025021009.051de285.dcdowse@gmx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/10/25 Daniel C. Dowse <dcdowse@gmx.net>

> On Sat, 24 Oct 2009 01:08:21 -0600
> Kelly Martin <kellymartin@gmail.com> wrote:
>
> > Greetings, here's a simple question for the FreeBSD gurus out there. I
> > have several servers running cron scripts daily for me, and they all
> > send me e-mail with their output. Regardless of which server it is,
> > each of these e-mails have the From: address looking exactly the same.
> > They all say they are from the "Cron Daemon". Fine, but I'd like to
> > know more clearly which server the cron output is from.
> >
> > How can I change the From: address of these emails to "Myserver Cron
> > Daemon" instead? I know cron runs as the user, so it's not immediately
> > obvious to me how to change the From: field. Already the subject line
> > says something like "Cron <root@Myserver> ..." but this doesn't stand
> > out enough for my tired eyes.
>
> Why don`t  you just create some filter rules in your mua ?
> It may makes it clear for you if you create a folder for each host
> and filter your msg on receiving ?
>
> e.g.
>
> Inbox
> ...
> CronDir
>        - Host 1
>        - Host 2
>        ....
>
>
> Cheers
>
> Daniel
>
> --
> Just because I don`t care - Doesn`t mean I don`t understand !
> -- Homer J. Simpson
>
>
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscribe@freebsd.org"
>


The simplist way to do it is get you scripts to print out a to, from and
subject line at the top of their output containing the information you want.
eg

To: your@mailbox.com
From: scriptname@hostname.com
Subject: scriptname, hostname

other script output


Then in the cron pipe the output into sendmail with the t flag

eg

1 1 * * * somescript 2>&1 | /usr/sbin/sendmail -t

you will then get the loverly named emails



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d36406630910251019g74ab55cclc4e829ec35b3cd35>