Logs more than 2 years before are included into current daily logs with huge sizes
What's going wrong?
Logs more than 2 years before are included into current daily logs with huge sizes
How could we reproduce this issue?
May not be a reproducible if issue, just wondered if this kind of issue had been reported before that it show a specific pattern.
Supporting information
Hello, last week our logrotate show too much CPU usage > 130% so we should have stopped using it.
It has worked fine for months with daily logging option, with less than 10MB size for a log.
The conf is
max_size 10M
retain 30
compress false
dateFormat YYYY-MM-DD_HH-mm-ss x
workerInterval 30
rotateInterval 0 0 * * *
rotateModule true
Analyzing error logs, I have found some odds that I want to ask the developers' opinions.
- PM2 logrotate started creating logs that include the oldest logs up to 2 years before, where the PM2 daemon starting working. The start time was around 4/15/24 16:31:02 as shown in the file name. (first photo)
- The first out.log size was created 4/15/24 16:31:02 with 3.6G that includes logs between 2022 Jan ~ 2023 Oct, then the second out.log was created 30 seconds later 4/15/24 16:31:32 with 3.4G that includes logs between 2022 Jan ~ 2023 Sep, which is shorter term than the first one. (second photo)
- Then for the next ones, it has the same pattern as 1) in 30 seconds 2), for shorter term, 3) therefore with 0.2G less size. (second photo)
- What I found weird was that in the head of monproxy-error__2024-04-15_16-31-02.log file, that is one of very first error files, I could read the "Cannot set property 'time' of null" error, which had tried to set the time of system info. There I guess they might have failed to read the process/server system info, then they failed to set the time of the system info that might end up being bugs of logrotate. (last two photos)
# Run the following commands
$ pm2 report
Thank you in advance. Luke
See https://github.com/Unitech/pm2/tree/master?tab=readme-ov-file#log-management, specifically the big about pm2-logrotate.