Balachandar
Balachandar

Reputation: 1628

logrotate not rotating logs based on size

I am using logrotate to rotate the test.log log files available in the directory /var/test/log. Below is the snippet of logrotate configuration file

DO NOT MODIFY THIS FILE.

/var/test/log/test.log { daily nocompress copytruncate missingok rotate 10 size 2M }

As seen in the configuration, the size of the file should be 2Mb and if the file grows beyond this it should get rotated, but it is not happening when i try to execute the below command

/usr/sbin/logrotate -d /var/test/testlogrotate reading config file /var/test/testlogrotate reading config info for /var/test/log/test.log

Handling 1 logs

rotating pattern: /var/test/log/test.log 2097152 bytes (10 rotations) empty log files are rotated, old logs are removed considering log /var/test/log/test.log log needs rotating rotating log /var/test/log/test.log, log->rotateCount is 10 renaming /var/test/log/test.log.10 to /var/test/log/test.log.11 (rotatecount 10, logstart 1, i 10), renaming /var/test/log/test.log.9 to /var/test/log/test.log.10 (rotatecount 10, logstart 1, i 9), renaming /var/test/log/test.log.8 to /var/test/log/test.log.9 (rotatecount 10, logstart 1, i 8), renaming /var/test/log/test.log.7 to /var/test/log/test.log.8 (rotatecount 10, logstart 1, i 7), renaming /var/test/log/test.log.6 to /var/test/log/test.log.7 (rotatecount 10, logstart 1, i 6), renaming /var/test/log/test.log.5 to /var/test/log/test.log.6 (rotatecount 10, logstart 1, i 5), renaming /var/test/log/test.log.4 to /var/test/log/test.log.5 (rotatecount 10, logstart 1, i 4), renaming /var/test/log/test.log.3 to /var/test/log/test.log.4 (rotatecount 10, logstart 1, i 3), renaming /var/test/log/test.log.2 to /var/test/log/test.log.3 (rotatecount 10, logstart 1, i 2), renaming /var/test/log/test.log.1 to /var/test/log/test.log.2 (rotatecount 10, logstart 1, i 1), renaming /var/test/log/test.log.0 to /var/test/log/test.log.1 (rotatecount 10, logstart 1, i 0), copying /var/test/log/test.log to /var/test/log/test.log.1 truncating /var/test/log/test.log removing old log /var/test/log/test.log.11

but i don't see any of the files like test.log.1 in /var/test/log directory. Also i could see that the size of the test.log file to be 2.3Mb.

Help me in trouble shooting this issue.

Upvotes: 0

Views: 1278

Answers (1)

baf
baf

Reputation: 4691

You are using -d which implies debug mode of logrotate. In debug mode logrotate only simulates its actions. No real actions are taken. From man page:

-d, --debug

Turns on debug mode and implies -v. In debug mode, no changes will be made to the logs or to the logrotate state file.  

Upvotes: 1

Related Questions