DEV Community

Discussion on: Linux: systemd-unit files edit, restart on failure and email notifications

Collapse
 
jmon12 profile image
jmon12 • Edited

I just implemented something very similar and struggled with the email not being sent.
After some investigation, I found out that the cause was that mailx is sending messages asynchronously by default, which is not compatible with the way systemd works (see the last post here)

Therefore the following option to mail is necessary: sendwait, i.e. your full mail command would be:
/usr/bin/mailx -Ssendwait -s "[%i] failure notification" admin@example.com

Collapse
 
setevoy profile image
Arseny Zinchenko

Thanks, @jmon, it's interesting.
Although I'm using mailx via local ssmtp at my Arch Linux workstations (both at work and at home) for this - didn't notice such issues.

Collapse
 
jmon12 profile image
jmon12

I'm not at all an expert in that matter, and won't investigate further. It can probably help others in my situation.
However if you're interested, I can provide you some configuration information if you guide me a bit.
Anyway thank you for your very nice work!