From 2e760823c1262f9b3679879c5643db94cb4dc68b Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Thu, 8 Dec 2022 14:13:11 -0800 Subject: [PATCH] Replace logrotate cron file with (adapted) systemd timer file (#12921) Debian is shipping a systemd timer unit for logrotate, but we're also packaging in a cron job, which means both of them will run, potentially at the same time. Remove our cron file, and add an override to the shipped timer file to have it be run every 10 minutes. Fixes #12392. Signed-off-by: Saikrishna Arcot Signed-off-by: Saikrishna Arcot --- files/build_templates/sonic_debian_extension.j2 | 2 ++ files/image_config/cron.d/logrotate | 3 --- files/image_config/logrotate/timerOverride.conf | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 files/image_config/cron.d/logrotate create mode 100644 files/image_config/logrotate/timerOverride.conf diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index e29e9a21fc..b2b5f5035c 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -398,6 +398,8 @@ sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate sudo cp $IMAGE_CONFIGS/logrotate/rsyslog.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ sudo cp $IMAGE_CONFIGS/logrotate/logrotate-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM sudo cp $IMAGE_CONFIGS/logrotate/logrotate-config.sh $FILESYSTEM_ROOT/usr/bin/ +sudo mkdir -p $FILESYSTEM_ROOT/etc/systemd/system/logrotate.timer.d +sudo cp $IMAGE_CONFIGS/logrotate/timerOverride.conf $FILESYSTEM_ROOT/etc/systemd/system/logrotate.timer.d/ echo "logrotate-config.service" | sudo tee -a $GENERATED_SERVICE_FILE # Copy systemd-journald configuration files diff --git a/files/image_config/cron.d/logrotate b/files/image_config/cron.d/logrotate deleted file mode 100644 index 173a2abe2b..0000000000 --- a/files/image_config/cron.d/logrotate +++ /dev/null @@ -1,3 +0,0 @@ -# Attempt to rotate system logs once every 10 minutes. -# First kill any logrotate process(es) if they are still running, as they're most likely hung -*/10 * * * * root /usr/bin/pkill -9 logrotate > /dev/null 2>&1; /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1 diff --git a/files/image_config/logrotate/timerOverride.conf b/files/image_config/logrotate/timerOverride.conf new file mode 100644 index 0000000000..fff55f5d72 --- /dev/null +++ b/files/image_config/logrotate/timerOverride.conf @@ -0,0 +1,2 @@ +[Timer] +OnCalendar=*:00/10:00