[prev in list] [next in list] [prev in thread] [next in thread]
List: centos
Subject: Re: [CentOS] Issue with "ExecStartPost" attribute in systemd daemon fail
From: Gestió Servidors <sysadmin.caos () uab ! cat>
Date: 2019-11-22 12:06:58
Message-ID: 4fe4c224-149e-5666-6523-6a720f71ff34 () uab ! cat
[Download RAW message or body]
Hi,
it seems there is no difference in "systemctl status crond"
> (
El 22/11/2019 a las 13:00, \
centos-request@centos.org<mailto:centos-request@centos.org> escribió:
Message: 3
Date: Thu, 21 Nov 2019 14:41:25 +0100
From: Leon Fauster <leonfauster@googlemail.com><mailto:leonfauster@googlemail.com>
To: centos@centos.org<mailto:centos@centos.org>
Subject: Re: [CentOS] Issue with "ExecStartPost" attribute in systemd
daemon faile
Message-ID: <b58a12c2-5e5c-f7ce-d69d-d464538f1972@gmail.com><mailto:b58a12c2-5e5c-f7ce-d69d-d464538f1972@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Am 21.11.19 um 14:28 schrieb Gesti? Servidors:
Hello,
I'm trying to configure a daemon (I'm doing tests with "crond" daemon) to send me an \
email after daemon restart. My "crond.service" file is: # \
/etc/systemd/system/crond.service [Unit]
Description=Command Scheduler
After=auditd.service systemd-user-sessions.service time-sync.target
#OnFailure=crond-notify-email@%i.service
[Service]
EnvironmentFile=/etc/sysconfig/crond
ExecStart=/usr/sbin/crond -n $CRONDARGS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=10s
ExecStartPost=/bin/sh -c "/etc/systemd/system/test.sh"
[Install]
WantedBy=multi-user.target
My "test.sh" is very simple:
#!/bin/sh
echo "CROND is restarting" | /usr/bin/mailx -s "crond failure notification" \
myemailaddress@mydomain
As you can see, I have added lines "Restart=on-failure", "RestartSec=10s" and " \
ExecStartPost=/bin/sh -c "/etc/systemd/system/test.sh"" to the original crond.service \
daemon file. Then, I run "systemctl daemon-reconfigure" and, from one console, I run \
"kill -9 `pidof cron`" for restarting crond daemon. After it, I receive an email... \
But now, if I run again ""kill -9 `pidof cron`", I don't receive any mail... I have \
notice that if I run "systemctl daemon-reload" and then kill crond process, mail is \
sent perfectly... but if I don't run "systemctl daemon-reload", mail is sent ONLY \
first time...
Why?
What is "status" showing (systemctl status crond)? For both cases
(first/second kill)? Any differences?
--
Leon
_______________________________________________
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic