Managing cron and similar E-Mails from headless systems
gheskett at shentel.net
Fri Feb 17 16:00:16 UTC 2017
On Friday 17 February 2017 06:14:01 Chris Green wrote:
> I have several headless systems doing useful work around the place:-
> A Raspberry Pi providing local DNS and DHCP
> A Beaglebone Black on our boat monitoring temperatures and
> An old desktop doing backups in the garage
> Most of these have one or more cron jobs running periodic rsync
> backups, copying data, etc. If the cron job has an error then it
> sends E-Mail to the owner of the job ('chris' in most cases, might be
> root in a couple).
> It's (moderately) easy to set up an MTA and /etc/aliases so that the
> messages are sent to my normal E-Mail. However I can't come up with a
> straightforward way of indicating where the messsage is *from*.
> You can't just invent a domain name for the headless system because
> that gets the E-Mail rejected by intermediate systems that try and
> look up the sender host name. Cron doesn't seem to have any mechanism
> for setting the sender's name, cron errors just come from 'root@'.
> Can anyone suggest a neat way of handling this so that I know where
> the errors are coming from?
> Chris Green
A hosts file based home network should suffice to fix that. I did have it
setup to do that from 3 of the now 5 machines here, but the inability to
separate the messages into important turned the whole thing into spam
for me. Set your resolv.conf to include the commands:
So it will look at /etc/hosts first, failing to find a match there it
sends it to the router, which forwards it to your ISP's dns.
1. Set the hostname and domain name of your machines so they know who
2. run the same hosts file on all machines, which lists the local ip,
names, and aliases of the whole local network, 7 lines here plus the
obligatory localhost stuff, does it nicely. Then on the client
machines, I just set the MailTo: gene at coyote, and it magically appears
in my /var/spool/mail/gene queue. That in turn triggers a watcher script
to send kmail a getmail message over whatever message bus your system
uses, dbus here ATM, to go get the mail.
But unless you can make procmail (I use a fetchmail->procmail processing
chain here) send the unimportant stuff to /dev/null, you'll likely tear
it back down in a week or 2. You don't need to know, when logging into
one of the other machines, everytime you fat fingered the password. With
my short fat fingers, and 82 years of arthritis accumulated, very easily
Cheers, Gene Heskett
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
More information about the ubuntu-users