systemd-status-mail(8)

πŸ“¦ version 1.21+git.20241206, in opensuse-leap 16.0

πŸ’Œ systemd-status-mail(8) β€” the systemd-status-mail page, bestie edition πŸ’Œ

okay so this is a page from the System Manager's Manual, and it's about systemd-status-mail β€” yes that's the real name, don't come for me, the description calls it systemd-mail-status and we're just gonna hold both of those facts at once like the icons we are πŸ’…


✨ NAME ✨

systemd-status-mail β€” sends you a mail when a systemd.timer fails. it's giving "your unit ghosted you but at least your inbox knows" πŸŽ€

🌸 SYNOPSIS 🌸

/usr/libexec/systemd-status-mail
/usr/lib/systemd/system/systemd-status-mail@.service

like, those two paths, that's the whole vibe.

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea 🍡 β€” systemd-mail-status gets called by systemd-status-mail@.service when that service is wired up for the OnFailure and/or OnSuccess case of a systemd unit. (yes, OnSuccess too, it's not just a doom-and-gloom situation, we love range πŸ‘‘)

and then it sends an email to an address you can configure, and that email contains:

  • the name of the service
  • the hostname
  • the output of systemctl status --full <service>

that's it, that's the whole personality, and honestly? iconic. πŸ”₯

πŸ’– CONFIGURATION OPTIONS πŸ’–

these are the variables, go off:

  • ADDRESS="root@localhost" β€” the address the status mail gets sent to. default is literally the machine talking to itself, no cap.
  • FROM="root@myhostname" β€” the sender address of the status mail. who's it from? this. 🫢
  • HOSTNAME="" β€” the name of the host used as the domain for the from address (root@$HOSTNAME). it's lowkey the little nameplate on your envelope.
  • MAILER="sendmail" β€” the name of the mail client that actually sends the status mail. valid values are "sendmail" and "mailx", and by default "sendmail" is used. pick your fighter ⭐
  • RELAYHOST="" β€” the mail relay used by mailx(1), but only if it's specified and not empty. no relay, no relaying, simple as that.
  • MAILX_OPTIONS="" β€” extra options passed straight through to mailx(1). put your little extras here. πŸ™ˆ

πŸŽ€ CONFIGURATION FILES πŸŽ€

  • /usr/etc/default/systemd-status-mail β€” the vendor-provided config file. it contains the defaults, and you should probs not be messing with it fr fr.
  • /etc/default/systemd-status-mail β€” the admin-provided config file. the rule here is that it should only contain the variables which were changed by the system administrator compared to the vendor configuration file. so, like, only your deltas. don't dump the whole thing in there πŸ’€

🧚 Example 🧚

okay so imagine os-update(8) fails (😭) and you want to be informed. here's what you do: create a file called status-mail.conf in the /etc/systemd/system/os-update.service.d/ directory, and put this content in it:

[Unit]
OnFailure=systemd-status-mail@%n.service

and then β€” everytime os-update.service fails, a mail is send. yup. that's the whole trick. main character config file energy 🌈

reminder bestie: keep that content verbatim, %n is doing real work in there and it's not a typo, don't touch it πŸ™

⭐ SEE ALSO ⭐

os-update(8), mailx(1), sendmail(1), postfix(1)

go read those too, iykyk πŸ’œ

πŸ‘‘ AUTHOR πŸ‘‘

Thorsten Kukuk β€” the actual legend behind this page. we stan. 🫢


and that's a wrap on the os-update manual, December 2024 edition, systemd-status-mail(8) β€” thank you for coming to my ted talk, now go configure your OnFailure, slay, periodt πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from