Managing cron and similar E-Mails from headless systems
cl at isbd.net
Fri Feb 17 16:15:39 UTC 2017
On Fri, Feb 17, 2017 at 11:00:16AM -0500, Gene Heskett wrote:
> 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
> > batteries
> > An old desktop doing backups in the garage
> > etc.
> > 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:
> "nameserver local.address.of.router"
> "order hosts,dns"
> 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
> they are.
> 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
Erk, I've spent the last N years avoiding maintaining lots of hosts
files on my home LAN. I run dnsmasq on a raspberry pi to do it all
for me automatically.
> 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
I don't use any sort of mail fetcher, mail is delivered to my home
machine (which is on all the time) by SMTP.
More information about the ubuntu-users