I tested the patch, and seems it works as expected. #old version, reproduce bug hostname:~/logrotate# for i in `seq 1 100000` ; do echo some entry $i >> /tmp/some.log; done hostname:~/logrotate# cat /tmp/some.conf /tmp/some.log { rotate 4 weekly size 10 missingok notifempty compress delaycompress sharedscripts postrotate reload rsyslog >/dev/null 2>&1 || true endscript } hostname:~/logrotate# ./logrotate -d /tmp/some.conf ; echo $? reading config file /tmp/some.conf Handling 1 logs rotating pattern: /tmp/some.log 10 bytes (4 rotations) empty log files are not rotated, old logs are removed considering log /tmp/some.log log needs rotating rotating log /tmp/some.log, log->rotateCount is 4 dateext suffix '-20150317' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' previous log /tmp/some.log.1 does not exist renaming /tmp/some.log.4.gz to /tmp/some.log.5.gz (rotatecount 4, logstart 1, i 4), renaming /tmp/some.log.3.gz to /tmp/some.log.4.gz (rotatecount 4, logstart 1, i 3), renaming /tmp/some.log.2.gz to /tmp/some.log.3.gz (rotatecount 4, logstart 1, i 2), renaming /tmp/some.log.1.gz to /tmp/some.log.2.gz (rotatecount 4, logstart 1, i 1), renaming /tmp/some.log.0.gz to /tmp/some.log.1.gz (rotatecount 4, logstart 1, i 0), renaming /tmp/some.log to /tmp/some.log.1 running postrotate script running script with arg /tmp/some.log : " reload rsyslog >/dev/null 2>&1 || true " removing old log /tmp/some.log.5.gz error: error opening /tmp/some.log.5.gz: No such file or directory 1 hostname:~/logrotate# ./logrotate -v /tmp/some.conf ; echo $? reading config file /tmp/some.conf Handling 1 logs rotating pattern: /tmp/some.log 10 bytes (4 rotations) empty log files are not rotated, old logs are removed considering log /tmp/some.log log needs rotating rotating log /tmp/some.log, log->rotateCount is 4 dateext suffix '-20150317' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' previous log /tmp/some.log.1 does not exist renaming /tmp/some.log.4.gz to /tmp/some.log.5.gz (rotatecount 4, logstart 1, i 4), old log /tmp/some.log.4.gz does not exist renaming /tmp/some.log.3.gz to /tmp/some.log.4.gz (rotatecount 4, logstart 1, i 3), old log /tmp/some.log.3.gz does not exist renaming /tmp/some.log.2.gz to /tmp/some.log.3.gz (rotatecount 4, logstart 1, i 2), old log /tmp/some.log.2.gz does not exist renaming /tmp/some.log.1.gz to /tmp/some.log.2.gz (rotatecount 4, logstart 1, i 1), old log /tmp/some.log.1.gz does not exist renaming /tmp/some.log.0.gz to /tmp/some.log.1.gz (rotatecount 4, logstart 1, i 0), old log /tmp/some.log.0.gz does not exist log /tmp/some.log.5.gz doesn't exist -- won't try to dispose of it renaming /tmp/some.log to /tmp/some.log.1 running postrotate script 0 # after applying patch, compile new version and check hostname:~/logrotate# ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking whether gcc understands -c and -o together... yes checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for gcc option to accept ISO C99... -std=gnu99 checking for gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99 checking for poptParseArgvString in -lpopt... yes checking for getfscreatecon_raw in -lselinux... no checking for acl_get_file in -lacl... no checking for strptime... yes checking for qsort... yes checking for fork... yes checking for vfork... yes checking for madvise... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating test/Makefile config.status: executing depfiles commands hostname:~/logrotate# make clean Making clean in test make[1]: Entering directory `/root/logrotate/test' make[1]: Nothing to be done for `clean'. make[1]: Leaving directory `/root/logrotate/test' make[1]: Entering directory `/root/logrotate' test -z "logrotate" || rm -f logrotate rm -f *.o make[1]: Leaving directory `/root/logrotate' hostname:~/logrotate# make Making all in test make[1]: Entering directory `/root/logrotate/test' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/root/logrotate/test' make[1]: Entering directory `/root/logrotate' gcc -std=gnu99 -DPACKAGE_NAME=\"logrotate\" -DPACKAGE_TARNAME=\"logrotate\" -DPACKAGE_VERSION=\"3.8.9\" -DPACKAGE_STRING=\"logrotate\ 3.8.9\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"logrotate\" -DVERSION=\"3.8.9\" -D_GNU_SOURCE=1 -DHAVE_LIBPOPT=1 -DHAVE_STRPTIME=1 -DHAVE_QSORT=1 -DHAVE_FORK=1 -DHAVE_VFORK=1 -DHAVE_MADVISE=1 -I. -Wall -Werror -g -O2 -MT logrotate.o -MD -MP -MF .deps/logrotate.Tpo -c -o logrotate.o logrotate.c mv -f .deps/logrotate.Tpo .deps/logrotate.Po gcc -std=gnu99 -DPACKAGE_NAME=\"logrotate\" -DPACKAGE_TARNAME=\"logrotate\" -DPACKAGE_VERSION=\"3.8.9\" -DPACKAGE_STRING=\"logrotate\ 3.8.9\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"logrotate\" -DVERSION=\"3.8.9\" -D_GNU_SOURCE=1 -DHAVE_LIBPOPT=1 -DHAVE_STRPTIME=1 -DHAVE_QSORT=1 -DHAVE_FORK=1 -DHAVE_VFORK=1 -DHAVE_MADVISE=1 -I. -Wall -Werror -g -O2 -MT log.o -MD -MP -MF .deps/log.Tpo -c -o log.o log.c mv -f .deps/log.Tpo .deps/log.Po gcc -std=gnu99 -DPACKAGE_NAME=\"logrotate\" -DPACKAGE_TARNAME=\"logrotate\" -DPACKAGE_VERSION=\"3.8.9\" -DPACKAGE_STRING=\"logrotate\ 3.8.9\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"logrotate\" -DVERSION=\"3.8.9\" -D_GNU_SOURCE=1 -DHAVE_LIBPOPT=1 -DHAVE_STRPTIME=1 -DHAVE_QSORT=1 -DHAVE_FORK=1 -DHAVE_VFORK=1 -DHAVE_MADVISE=1 -I. -Wall -Werror -g -O2 -MT config.o -MD -MP -MF .deps/config.Tpo -c -o config.o config.c mv -f .deps/config.Tpo .deps/config.Po gcc -std=gnu99 -DPACKAGE_NAME=\"logrotate\" -DPACKAGE_TARNAME=\"logrotate\" -DPACKAGE_VERSION=\"3.8.9\" -DPACKAGE_STRING=\"logrotate\ 3.8.9\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"logrotate\" -DVERSION=\"3.8.9\" -D_GNU_SOURCE=1 -DHAVE_LIBPOPT=1 -DHAVE_STRPTIME=1 -DHAVE_QSORT=1 -DHAVE_FORK=1 -DHAVE_VFORK=1 -DHAVE_MADVISE=1 -I. -Wall -Werror -g -O2 -MT basenames.o -MD -MP -MF .deps/basenames.Tpo -c -o basenames.o basenames.c mv -f .deps/basenames.Tpo .deps/basenames.Po gcc -std=gnu99 -Wall -Werror -g -O2 -o logrotate logrotate.o log.o config.o basenames.o -lpopt make[1]: Leaving directory `/root/logrotate' hostname:~/logrotate# for i in `seq 1 100000` ; do echo some entry $i >> /tmp/some.log; done hostname:~/logrotate# ./logrotate -d /tmp/some.conf ; echo $? reading config file /tmp/some.conf Handling 1 logs rotating pattern: /tmp/some.log 10 bytes (4 rotations) empty log files are not rotated, old logs are removed considering log /tmp/some.log log needs rotating rotating log /tmp/some.log, log->rotateCount is 4 dateext suffix '-20150317' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' compressing log with: /bin/gzip renaming /tmp/some.log.4.gz to /tmp/some.log.5.gz (rotatecount 4, logstart 1, i 4), renaming /tmp/some.log.3.gz to /tmp/some.log.4.gz (rotatecount 4, logstart 1, i 3), renaming /tmp/some.log.2.gz to /tmp/some.log.3.gz (rotatecount 4, logstart 1, i 2), renaming /tmp/some.log.1.gz to /tmp/some.log.2.gz (rotatecount 4, logstart 1, i 1), renaming /tmp/some.log.0.gz to /tmp/some.log.1.gz (rotatecount 4, logstart 1, i 0), log /tmp/some.log.5.gz doesn't exist -- won't try to dispose of it renaming /tmp/some.log to /tmp/some.log.1 running postrotate script running script with arg /tmp/some.log : " reload rsyslog >/dev/null 2>&1 || true " 0 hostname:~/logrotate# ./logrotate -v /tmp/some.conf ; echo $? reading config file /tmp/some.conf Handling 1 logs rotating pattern: /tmp/some.log 10 bytes (4 rotations) empty log files are not rotated, old logs are removed considering log /tmp/some.log log needs rotating rotating log /tmp/some.log, log->rotateCount is 4 dateext suffix '-20150317' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' compressing log with: /bin/gzip renaming /tmp/some.log.4.gz to /tmp/some.log.5.gz (rotatecount 4, logstart 1, i 4), old log /tmp/some.log.4.gz does not exist renaming /tmp/some.log.3.gz to /tmp/some.log.4.gz (rotatecount 4, logstart 1, i 3), old log /tmp/some.log.3.gz does not exist renaming /tmp/some.log.2.gz to /tmp/some.log.3.gz (rotatecount 4, logstart 1, i 2), old log /tmp/some.log.2.gz does not exist renaming /tmp/some.log.1.gz to /tmp/some.log.2.gz (rotatecount 4, logstart 1, i 1), renaming /tmp/some.log.0.gz to /tmp/some.log.1.gz (rotatecount 4, logstart 1, i 0), old log /tmp/some.log.0.gz does not exist log /tmp/some.log.5.gz doesn't exist -- won't try to dispose of it renaming /tmp/some.log to /tmp/some.log.1 running postrotate script 0