Le vendredi 6 février 2015, 21:23:14 Mantas Mikulėnas a écrit : > On Fri, Feb 6, 2015 at 5:26 PM, George Karakougioumtzis < > mad-proffes...@hotmail.com> wrote: > > > Hi. Congrats for the near perfect job on systemd! I was searching for a > > directive to execute a script upon systemd service failure. I would like > > to receive desktop notifications about such failures. I stumbled upon > > OnFailure and FailureAction but these have hardcoded list of actions? > > > > One of those actions is "start an arbitrary unit", which could handle > notifications... Unfortunately it doesn't actually pass any failure > information to that unit. Hi,
OnFailure= can be an instanciated unit, like "OnFailure=failure@%i.service" then your failure@.service include this line [Service] Type=oneshot ExecStart=/usr/local/bin/user_notification %i then your notification script get failed service name as argv[1] > Maybe others will have better suggestions. for user notification I use this, I guess it's not optimal: #!/bin/bash user=$(loginctl list-sessions | grep seat0 | awk '{print $3}') if [ -n "$user" ] then export DISPLAY=:0 su $user -c "notify-send '$1 FAILED' -i /usr/share/icons/oxygen/48x48/status/dialog-warning.png " else echo "$1 FAILED " | wall fi _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel