Skip to content

Commit

Permalink
Only rotate non-empty nginx logs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcone committed Jun 25, 2024
1 parent 3cbf296 commit b1994c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions run/archiveloop
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

0 comments on commit b1994c4

Please sign in to comment.