On Mon, 2022-03-14 at 11:47 +0100, Marco d'Itri wrote: > On Mar 14, Paul Wise <p...@debian.org> wrote: > > > AFAICT OnSuccess/OnFailure services don't recieve the output of the > > succeeding/failing service. So the mail sending service needs to dig > > around in the systemd journal. Or make the service output go to a file, > > FIFO or socket and then send that to a mail. > Yes, this is true. These are the unit and script that I use, and I think > that Debian would benefit from having something like this available in > some common package. > > I think that there is still space for cron jobs and for having a cron > package installed by default, but also that packages should seriously > consider migrating their cron jobs to timer units.
From v251 (should be out soon-ish) processes spawned via OnFailure/OnSuccess will get the following env vars set automatically: $MONITOR_UNIT $MONITOR_SERVICE_RESULT $MONITOR_EXIT_CODE $MONITOR_EXIT_STATUS $MONITOR_INVOCATION_ID Besides, OnFailure/OnSuccess really should start templated units anyway, so that you get exactly one instance per invocation. So the pattern you noted with on-failure@n.service is the right thing anyway. -- Kind regards, Luca Boccassi
signature.asc
Description: This is a digitally signed message part