[systemd-devel] Restart and RestartSec in packaged .service files
Lennart Poettering
lennart at poettering.net
Thu Sep 1 07:26:56 PDT 2011
On Thu, 01.09.11 16:25, Lennart Poettering (lennart at poettering.net) wrote:
>
> On Thu, 01.09.11 13:07, Reindl Harald (h.reindl at thelounge.net) wrote:
>
> > > and at the same time take other action like potentially trigger abrt to send bug report or
> > > revert changes and restart the daemon etc. as opposed to pipe a simple mail notification
> > > to root and systemd provides exactly that to admins via OnFailure= see man systemd.unit
> > > for details...
> >
> > http://0pointer.de/public/systemd-man/systemd.unit.html does not contain the word "mail"
> > "RestartNotifyMail=root" would be what is needed in SOHO environments!
> >
> > well but a) there are missing options and b) OnFailure is simply a joke
> > if i say "Restart=always" then OnFailure is NOT triggered
>
> if this is the case, then this should be considered a bug I
> guess. Please file it.
>
> > if i say "Restart=always" i want a mail if this happens
> > not a own unit-file
>
> write a unit file that sends a mail, something like this:
>
> send-mail-on-failure at .service:
> <snip>
> [Unit]
> Description=Send mail on failure of %I
>
> [Service]
> ExecStart=/path/to/my/script.sh %I
> </snip>
>
> /path/to/my/script.sh:
> <snip>
> #!/bin/sh
>
> (
> echo "$1 crashed, do something, sir!"
> echo "here's the systemctl status output:"
> systemctl status "$1"
> ) | mail lennart -s "OMG! PONIES!"
> </snip>
>
> And then add OnFailure=send-mail-on-failure@%P to your units where you
> want a mail to be sent.
"OnFailure=send-mail-on-failure@%P.service" I meant. Sorry for the
confusion.
All untested, but you get the idea...
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list