From b1994c4574cb5027c366cc5d438ebfe1ca7803c9 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Tue, 25 Jun 2024 11:39:41 -0700 Subject: [PATCH] Only rotate non-empty nginx logs --- run/archiveloop | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run/archiveloop b/run/archiveloop index 350b28ff..83937786 100755 --- a/run/archiveloop +++ b/run/archiveloop @@ -726,8 +726,14 @@ function snapshotloop { function logrotator { while true do - mv -f /var/log/nginx/access.log /var/log/nginx/access.log.prev || true - mv -f /var/log/nginx/error.log /var/log/nginx/error.log.prev || true + if [ -s /var/log/nginx/access.log ] + then + mv -f /var/log/nginx/access.log /var/log/nginx/access.log.prev || true + fi + if [ -s /var/log/nginx/error.log ] + then + mv -f /var/log/nginx/error.log /var/log/nginx/error.log.prev || true + fi if [ -e /var/run/nginx.pid ] then kill -USR1 "$(cat /var/run/nginx.pid)"