[GH-ISSUE #18] Wrong script for systemd startup #10

Closed
opened 2026-05-05 14:58:22 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @fmalfatto on GitHub (Apr 16, 2014).
Original GitHub issue: https://github.com/darold/sendmailanalyzer/issues/18

I'm not able to stop sendmailanalyzer via
"systemctl stop sendmailanalyzer.service"
under opensuse 12.3.

The service definition has the following line:
ExecStop=/bin/kill -TERM sendmailanalyzer

But kill needs the process id, not the process name.

I tried to change that line to
ExecStop=/bin/kill -TERM $MAINPID
as from systemd docs, but it does not work.

That bug make me unable to have senmailanalyze restarted after syslog rotation, and it fails every night.

Originally created by @fmalfatto on GitHub (Apr 16, 2014). Original GitHub issue: https://github.com/darold/sendmailanalyzer/issues/18 I'm not able to stop sendmailanalyzer via "systemctl stop sendmailanalyzer.service" under opensuse 12.3. The service definition has the following line: ExecStop=/bin/kill -TERM sendmailanalyzer But kill needs the process id, not the process name. I tried to change that line to ExecStop=/bin/kill -TERM $MAINPID as from systemd docs, but it does not work. That bug make me unable to have senmailanalyze restarted after syslog rotation, and it fails every night.
Author
Owner

@darold commented on GitHub (Apr 16, 2014):

You can use pkill instead of kill like follow if you have such utility installed:

ExecStop=/usr/bin/pkill -TERM sendmailanalyzer

or use the pid file instead:

ExecStop=/bin/kill -TERM  `cat /var/run/sendmailanalyzer.pid`

or something like that. The path of the pid file is defined into sendmailanalyzer.conf with directive PID_DIR.

Or better is to restart sendmailanalyzer directly from syslog rotation. In my /etc/logrotate.d/rsyslog I have the following in the postrotate part:

        postrotate
            reload rsyslog >/dev/null 2>&1 || true
            /bin/kill -HUP `cat /var/run/sendmailanalyzer.pid`  2>/dev/null || true
        endscript

Let me know what's solves your issue.

<!-- gh-comment-id:40608385 --> @darold commented on GitHub (Apr 16, 2014): You can use pkill instead of kill like follow if you have such utility installed: ``` ExecStop=/usr/bin/pkill -TERM sendmailanalyzer ``` or use the pid file instead: ``` ExecStop=/bin/kill -TERM `cat /var/run/sendmailanalyzer.pid` ``` or something like that. The path of the pid file is defined into sendmailanalyzer.conf with directive PID_DIR. Or better is to restart sendmailanalyzer directly from syslog rotation. In my /etc/logrotate.d/rsyslog I have the following in the postrotate part: ``` postrotate reload rsyslog >/dev/null 2>&1 || true /bin/kill -HUP `cat /var/run/sendmailanalyzer.pid` 2>/dev/null || true endscript ``` Let me know what's solves your issue.
Author
Owner

@fmalfatto commented on GitHub (Apr 16, 2014):

Having pkill installed, in sendmailanalyzer.service I changed to
ExecStop=/usr/bin/pkill -TERM sendmailanalyzer

and in /etc/logrotate.d/syslog I added in postrotate:
/usr/bin/systemctl restart sendmailanalyzer.service > /dev/null 2>&1 || true

All is working perfectly now! Ty very much for fast and clean help!

<!-- gh-comment-id:40622567 --> @fmalfatto commented on GitHub (Apr 16, 2014): Having pkill installed, in sendmailanalyzer.service I changed to ExecStop=/usr/bin/pkill -TERM sendmailanalyzer and in /etc/logrotate.d/syslog I added in postrotate: /usr/bin/systemctl restart sendmailanalyzer.service > /dev/null 2>&1 || true All is working perfectly now! Ty very much for fast and clean help!
Author
Owner

@darold commented on GitHub (Apr 16, 2014):

Ok, I will drop a line about that in documentation

<!-- gh-comment-id:40622826 --> @darold commented on GitHub (Apr 16, 2014): Ok, I will drop a line about that in documentation
Author
Owner

@fmalfatto commented on GitHub (Jan 6, 2016):

Small correction:
the reported line in sendmailanalyzer.service
ExecStop=/bin/kill -TERM cat /var/run/sendmailanalyzer.pid
does not work in OpenSuse 13.1, reporting "No such process" .

The correct line would be:
ExecStop=/bin/bash -c "/bin/kill -TERM /usr/bin/cat /var/run/sendmailanalyzer.pid"

<!-- gh-comment-id:169294952 --> @fmalfatto commented on GitHub (Jan 6, 2016): Small correction: the reported line in sendmailanalyzer.service ExecStop=/bin/kill -TERM `cat /var/run/sendmailanalyzer.pid` does not work in OpenSuse 13.1, reporting "No such process" . The correct line would be: ExecStop=/bin/bash -c "/bin/kill -TERM `/usr/bin/cat /var/run/sendmailanalyzer.pid`"
Author
Owner

@darold commented on GitHub (Jan 6, 2016):

Thanks for the report, latest commit be3083f adds your patch.

Best regards,

<!-- gh-comment-id:169296648 --> @darold commented on GitHub (Jan 6, 2016): Thanks for the report, latest commit be3083f adds your patch. Best regards,
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/sendmailanalyzer#10
No description provided.