From d2074849fcf32c7e609424ab22eb7c9201bad446 Mon Sep 17 00:00:00 2001 From: DavidZagury <32644413+DavidZagury@users.noreply.github.com> Date: Sat, 28 Sep 2024 21:38:03 +0300 Subject: [PATCH] Make sure logrotate send rsyslog HUP signal only if it is already running (#19947) #### Why I did it We encounter an error in the log, which came from the call to logrotate while rsyslog is not running. ### How I did it Config logrotate to check that the HUP signal will only send when rsyslog is running. --- files/image_config/logrotate/rsyslog.j2 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/image_config/logrotate/rsyslog.j2 b/files/image_config/logrotate/rsyslog.j2 index 4c40da24d256..b0a7ff7e7002 100644 --- a/files/image_config/logrotate/rsyslog.j2 +++ b/files/image_config/logrotate/rsyslog.j2 @@ -19,7 +19,9 @@ delaycompress sharedscripts postrotate - /bin/kill -HUP $(cat /var/run/rsyslogd.pid) + if [ -f /var/run/rsyslogd.pid ]; then + /bin/kill -HUP $(cat /var/run/rsyslogd.pid) + fi endscript } @@ -116,7 +118,9 @@ pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true fi else - /bin/kill -HUP $(cat /var/run/rsyslogd.pid) + if [ -f /var/run/rsyslogd.pid ]; then + /bin/kill -HUP $(cat /var/run/rsyslogd.pid) + fi fi endscript }