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 at 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 at .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