> No, it didn't, just worked silently. Could you please instruct me on how to > emulate correct logrotate run with lots of debugging information? I guess I > will have to edit /var/lib/logrotate/status, so that logrotate believes it > hasn't done it's job for long (what if I change the year from 2018 to 2017 in > all the lines?), then fabricate some big log files kern.log, daemon.log, ... > (will random data from urandom suffice, or should it be plain text?), and > then, maybe, logrotate -d as root manually?
The follwing script should do it (even as non-root): <<<<< snip >>>>> #!/bin/sh set -eu TEST_PATH=/tmp/logrotate TEST_LOG="$TEST_PATH/test.log" TEST_STATE="$TEST_PATH/state" TEST_CONF="$TEST_PATH/test.conf" mkdir -p "$TEST_PATH" dd if=/dev/random of="$TEST_LOG" bs=1M count=10 cat <<EOF > "$TEST_STATE" logrotate state -- version 2 "$TEST_LOG" 2018-1-1-0:0:0 EOF cat <<EOF > "$TEST_CONF" $TEST_LOG { rotate 4 weekly missingok notifempty compress delaycompress create } EOF /usr/sbin/logrotate --verbose --state="$TEST_STATE" "$TEST_CONF" <<<<< snip >>>>> The output for me is: <<<<< snip >>>>> $ ./logrotate.sh dd: warning: partial read (88 bytes); suggest iflag=fullblock 0+10 records in 0+10 records out 798 bytes copied, 0,000645187 s, 1,2 MB/s reading config file /tmp/logrotate/test.conf Reading state from file: /tmp/logrotate/state Allocating hash table for state file, size 64 entries Creating new state Handling 1 logs rotating pattern: /tmp/logrotate/test.log weekly (4 rotations) empty log files are not rotated, old logs are removed considering log /tmp/logrotate/test.log Now: 2018-08-25 13:13 Last rotated at 2018-01-01 00:00 log needs rotating rotating log /tmp/logrotate/test.log, log->rotateCount is 4 dateext suffix '-20180825' glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' previous log /tmp/logrotate/test.log.1 does not exist renaming /tmp/logrotate/test.log.4.gz to /tmp/logrotate/test.log.5.gz (rotatecount 4, logstart 1, i 4), old log /tmp/logrotate/test.log.4.gz does not exist renaming /tmp/logrotate/test.log.3.gz to /tmp/logrotate/test.log.4.gz (rotatecount 4, logstart 1, i 3), old log /tmp/logrotate/test.log.3.gz does not exist renaming /tmp/logrotate/test.log.2.gz to /tmp/logrotate/test.log.3.gz (rotatecount 4, logstart 1, i 2), old log /tmp/logrotate/test.log.2.gz does not exist renaming /tmp/logrotate/test.log.1.gz to /tmp/logrotate/test.log.2.gz (rotatecount 4, logstart 1, i 1), old log /tmp/logrotate/test.log.1.gz does not exist renaming /tmp/logrotate/test.log.0.gz to /tmp/logrotate/test.log.1.gz (rotatecount 4, logstart 1, i 0), old log /tmp/logrotate/test.log.0.gz does not exist log /tmp/logrotate/test.log.5.gz doesn't exist -- won't try to dispose of it renaming /tmp/logrotate/test.log to /tmp/logrotate/test.log.1 creating new /tmp/logrotate/test.log mode = 0644 uid = 1000 gid = 1000 $ ls -la logrotate/ total 36K drwxr-xr-x 2 christian christian 4,0K Aug 25 13:13 . drwxrwxrwt. 20 root root 20K Aug 25 13:13 .. -rw-r--r-- 1 christian christian 74 Aug 25 13:13 state -rw-r--r-- 1 christian christian 151 Aug 25 13:13 test.conf -rw-r--r-- 1 christian christian 0 Aug 25 13:13 test.log -rw-r--r-- 1 christian christian 798 Aug 25 13:13 test.log.1 <<<<< snip >>>>>