Re: Issue with "ExecStartPost" attribute in systemd daemon faile

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



Gestió Servidors wrote:

Hellos,

Yes, I did some tests with "OnFailure" attribute, but the result was the same: system didn't sent any mail.
Daemon and script files were:

   *   crond.service:
      *   [Unit]
Description=Command Scheduler
After=auditd.service systemd-user-sessions.service time-sync.target
OnFailure=crond-notify-email.service
[Service]
EnvironmentFile=/etc/sysconfig/crond
ExecStart=/usr/sbin/crond -n $CRONDARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target


   *   crond-notify-email.service:
      *   [Unit]
Description=crond failure email notification
After=crond.service
Requires=crond.service
[Service]
Type=oneshot
ExecStart=/etc/systemd/system/mail-notification.sh


   *   /etc/systemd/system/mail-notification.sh
      *   #!/bin/bash
echo "Crond restarted" | /usr/bin/mailx -s "Crond failure notification" myemail@mydomain

After "systemctl daemon-reload" and "kill -9 `pidof crond`", message log are:
Nov 22 11:04:36 mysystem systemd: crond.service: main process exited, code=killed, status=9/KILL
Nov 22 11:04:36 mysystem systemd: Unit crond.service entered failed state.
Nov 22 11:04:36 mysystem systemd: Triggering OnFailure= dependencies of crond.service.
Nov 22 11:04:36 mysystem systemd: crond.service failed.
Nov 22 11:04:41 mysystem systemd: crond.service holdoff time over, scheduling restart.
Nov 22 11:04:41 mysystem systemd: Stopped Command Scheduler.
Nov 22 11:04:41 mysystem systemd: Started Command Scheduler.
Nov 22 11:04:41 mysystem systemd: Starting crond failure email notification...
Nov 22 11:04:41 mysystem systemd: Started crond failure email notification.

... but I don't receive any email...

Why?

Works for me - but I have the extras for crond.service (or any other service) as:

 [Unit]
 OnFailure=unit-status-mail@%n.service

 [Service]
 Restart=on-failure
 RestartSec=5s

and unit-status-mail@.service contains something like:

 [Unit]
 Description=Unit Status Mailer Service
 After=network.target

 [Service]
 Type=simple
 ExecStart=/path/to/mailer/script

I got this info a while ago from http://northernlightlabs.se/systemd.status.mail.on.unit.failure - but that no longer exists ...

James Pearson
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux