When I use logrotate with this configuration:
/home/ubuntu/.pm2/logs/* {
rotate 2
size 200k
missingok
notifempty
compress
delaycompress
copytruncate
create 0640 ubuntu ubuntu
}
My file (let's call it test
) doesn't get rotated until it reaches 200k. Upon it reaching 200k it gets copytruncate-ed. I am left with test
at 0k (correct!) and test.1
at > 200k.
The problem is that the next day I shall get test
> 0k (growing correctly), test.1
at 0k and test.1.1
at > 200k. As days progress, I will eventually get an endless number of test.1.1.1.1...
at 0k with the last one at > 200k created yesterday.
My original idea was to have two files, test
at whatever size less than 200k and another, older, log file only.
I need to use copytruncate as if I don't the PM2 process is going to keep writing to the old log file.
What am I doing wrong?