Re: Debian Buster release to partially drop non-systemd support
On Wed, Oct 17, 2018 at 08:33:47PM -0700, Russ Allbery wrote:
MAILTO was the main thing that I remember missing in terms of pure
functionality.
This is not a complete substitute for all uses of MAILTO, but I found
the following useful so I share it in case you weren't aware of it.
Define a service specifically designed for sending status emails:
status-email-user@.service:
[Service]
Type=oneshot
ExecStart=-/usr/local/bin/systemd-email %i
User=nobody
Group=systemd-journal
(I also switch on a little status LED I have with another ExecStart
line)
/usr/local/bin/systemd-email:
systemctl status --full "$1" | mail -s "unit $1 failed" root
Put an OnFailure= line in systemd units that you want to mail you if
they go wrong
[Unit]
OnFailure=status-email-user@%n.service
I think I probably got this from the Arch wiki and it suffers many of
the problems you outlined in your follow-on paragraph (needing a
separate unit, to the timer, an external shell script, etc.)
Since I switched to this, I've made the scripts I run on timers much
more verbose in the non-failure case, because I know I am not going
to generate mail. And this has turned out to be a good habit, because
I have a lot of useful information in my journal.
--
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Jonathan Dowland
⢿⡄⠘⠷⠚⠋⠀ https://jmtd.net
⠈⠳⣄⠀⠀⠀⠀ Please do not CC me, I am subscribed to the list.
Reply to: