G McAlister wrote:
On 07/05/2023 13:38, Per Jessen wrote:
Per Jessen wrote:
Hmm, slight twist - I want the output whenever there is any, i.e. same behaviour as with cron. I guess I have to use OnSuccess= and OnFailure= both. I'll check it out.
Just to finish off that bit - systemd-status-mail does not seem to have a way of specifying the MAILTO recipient, per timer? (I may have overlooked it). I also spent quite a bit of time wrestling with Failed to enqueue OnFailure= job, ignoring: Unit systemd-status-mail@myfirst.service.service not found. Until I realised I would need to install the systemd-status-mail service in my user config too :-(
For me, OnSuccess and OnFailure didn't do what I needed ( an email notification regardless of success or failure but showing which).
Right, that's pretty much what I am after - we use quite a few cron jobs for things like regular reports, log extracts, all kinds of stuff. Usually daily jobs, with output just sent to MAILTO.
I did this for notification of my nightly rmt job: In the systemd rmt-server-mirror.service file, add an ExecStopPost: ExecStopPost=/bin/bash "/usr/local/sbin/svcstop.sh"
Ah, I hadn't thought of that option.
/usr/bin/mailx -Ssendwait -s "$SUBJECT" "$EMAIL" <<< "$JRNL"
Right, that's the sort of thing I imagined too, I would just prefer to leave the EMAIL definition in the timer job (somehow). Maybe with an instance variable. -- Per Jessen, Zürich (20.8°C) Member, openSUSE Heroes (2016 - present) We're hiring - https://en.opensuse.org/openSUSE:Heroes