[systemd-devel] Antw: [EXT] Re: Q: logrotate and "systemctl kill -s HUP ..."

Ulrich Windl Ulrich.Windl at rz.uni-regensburg.de
Wed Sep 30 10:52:19 UTC 2020


>>> Mantas Mikulenas <grawity at gmail.com> schrieb am 30.09.2020 um 12:26 in
Nachricht
<CAPWNY8UwPxu4jCLc6zbbYh=zHxHaYPjS86oW45WsDushq0QhkA at mail.gmail.com>:
> On Wed, Sep 30, 2020 at 11:24 AM Ulrich Windl <
> Ulrich.Windl at rz.uni-regensburg.de> wrote:
> 
>> Hi!
>>
>> I have a problem with logrotate: My postrotate command does not seem to
>> send a HUP signal. However the files are rotated.
>> I'm using this (not preferred way, I know):
>>
>> ...
>>         postrotate
>>                 test -s '/var/run/iotwatch-LOC1/iotwatch-LOC1.pid' &&
>> systemctl kill -s HUP --kill-who=main iotwatch at LOC1.service 
>>         endscript
>> ...
>>
>> I've verified that the PID file exists (just rebooted the server a few
>> minutes ago):
>> # ll /var/run/iotwatch-LOC1/iotwatch-LOC1.pid
>> -rw-r--r-- 1 root root 5 Sep 30 10:07
>> /var/run/iotwatch-LOC1/iotwatch-LOC1.pid
>>
> 
> Do you need to check for it in the first place?
> 
> Does the same command work from interactive CLI?
> 
> 
>>
>> My service would log the arrival of any HUP signal, but it didn't. Also in
>> syslog I could not find any error message related to "systemctl kill".
>> What might be wrong?
>>
>> My service is using ExecStartPre, ExecStartPost, and ExecStart. Could
>> systemd be confused about "--kill-who=main" then?
> 
> 
> --kill-who=main means the signal will be sent to the "main" process that
> was started from ExecStart (shown as "Main PID:" in systemctl status).
> 
> The more preferred way of doing this is to have "ExecReload=/bin/kill -HUP
> $MAINPID" and then `systemctl reload foo.service`.
> 
> Sending HUP to ExecStartPre and ExecStartPost doesn't make sense, since
> those are supposed to be short-running commands – they are not allowed to
> actually *have* daemons.

Hi!

Thanks for the suggestions. Before I work them out, I have a simple question
(systemd-228 of SLES12):
Systemd loggs quite a lot; does it log a message when it sends a signal to a
process (or fails to do so)? If so it would help to isolate the problem. I
could not see any message, so my guess is that the test for the PID file does
not work as intended.

However the dosc says:
              The lines between postrotate and endscript (both of  which 
must
              appear  on  lines  by  themselves)  are executed (using
/bin/sh)
              after the log file is rotated.

So the "&&" should work, but maybe a backslash is needed at the end of the
line (it is not when entering the command interactively).

Regards,
Ulrich


> 
> -- 
> Mantas Mikulėnas





More information about the systemd-devel mailing list