[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: migration from cron.daily to systemd timers



On Wed, Jan 08, 2020 at 07:12:17PM -0800, Russ Allbery wrote:
Michael Stone <mstone@debian.org> writes:
On Thu, Jan 09, 2020 at 02:09:12AM +0000, Paul Wise wrote:

This is the main reason I haven't switched to systemd timers for my
personal crontab, I have some jobs that generate output (diffs of
various things mostly) but don't fail. There doesn't appear to be any
tool to monitor a tool and send a mail if it generates output or fails,
in the way that cron does.

mail -E ?

Specifically:

   ExecStart=/bin/sh -c '/path/to/job | /usr/bin/mail -E'

in the service unit triggered by the timer unit should work, I think.
(I've not tested it.)

May need something like (job || echo Job failed) 2>&1 | mail -E
or even

(job 2>&1 || echo Job failed) | tee /dev/stderr | mail -E

depending on the specific requirements, but in general this should be pretty straightforward


Reply to: