On Sun, 07 May 2023 15:55:33 +0200 Per Jessen <per@opensuse.org> wrote:
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.
The arch wiki page mentioned some utility that would parse a cron file and implement systemd-timers, including mail. Perhaps that's worth a look? (I haven't myself, sorry)
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.