Re: need for open-minded help with popularity-contest with systemd timer

Richard Lewis <richard.lewis.debian-gM/[email protected]> Sun, 26 Jul 2026 09:52:37 +0100
Newsgroups gmane.linux.debian.devel.general
Message-ID <[email protected]>
Simon Richter <[email protected]> writes:

> Hi,
>
> On 7/25/26 21:14, Richard Lewis wrote:
>
>> - the timer should start a service that runs new-script, and then does a "sleep 10" to ensure exim can deliver the email before
>>    systemd kills the unit (see #1106030)
>>    (better workarounds welcomed)
>
> Can we create a systemd service that sends a mail, and has its own
> lifetime and permissions?

yes please!

I think all you need is:

1. a command that takes mail as input, and then passes it to the server
(this command is run in the caller's cgroup - it will block only until
the "passes off" part is done, and maybe some basic syntax checking -
then it can exit)

2. a server that waits for input, and then calls mail(1) to deliver
it. (I think as long as the server is in a separate systemd .service
this will all work, as whatever processes the local mta start wont be
killed if the .service is persistent.)

It would the server would need to cope with multiple concurrent requests
or queue requests (becuase lots of cronjob-type things wanting to send
reports might run at once) (this is the point at which things exceed my
knowledge!), and have some way of bouncing back errors (maybe mail(1)
already does enough? probably just mail the sender like an smtp server
would). Maybe it needs some kind of queue so that if the system is
rebooted before the mail is sent things dont get lost.

I think the server would only need to listen locally (again beyond my
knowledge - the word "socket" springs to mind) and wouldnt need anything
special for permissions - the local mta is already enforcing any
restrictions.

None of this should cause issues on non-systemd systems i wouldnt think
(it would be entirely superfluous, but maybe other init systems putting
things in cgroups would have the same issue. i think it might also
enable sending mail from a container to the host)