1

Few days ago, my webapp stopped work, i checked on the server and it was stopped in pm2 and didn't want restart. I figured that the disk was full (25Gb) so i took an upgrade to 80Gb and installed logrotate but today, 2 days after, the disk is full again.

I did a flush logs command with sudo pm2 flush, which did bring it from 80Gb to 61Gb. Then i figured that the .pm2/logs folder was 57Gb and i see 150 log files like "sign-out__2021-02-13_05-36-03.log" for the app for a single day, how can i fix that?

Here my logrotate default config:

"pm2-logrotate": {
"max_size": "10M",
"retain": "30",
"compress": false,
"dateFormat": "YYYY-MM-DD_HH-mm-ss",
"workerInterval": "30",
"rotateInterval": "0 0 * * *",
"rotateModule": true
},
"module-db-v2": {
"pm2-logrotate": {}
}
}

If i understand it well it shouldn keep more than 30 of 10Mb max so 57Gb is not normal.

I deleted all sign-out__2021-02-13_05-36-*.log files and down to 8Gb

I stopped logrotate for now and its ok but would like to know how to solve this issue

Thank you in advance

Christophe
  • 145
  • 1
  • 1
  • 12

1 Answers1

0

There are bugs in pm2-logrotate. But the values in your configuration file can also be improved.

For example, a configuration like this works much better in your situation.

"pm2-logrotate": {
    "max_size": "10M",
    "retain": "30",
    "compress": true,
    "dateFormat": "YYYY-MM-DD_HH-mm-ss",
    "workerInterval": "3600",
    "rotateInterval": "0 0 * * *",
    "rotateModule": true
},
"module-db-v2": {
    "pm2-logrotate": {}
}

Retain 30 : If your logs folder has 5 file, 150 files will be retained(5*30) Set compress to true : rotated files will be compressed and saved to save space WorkerInterval : value is in milliseconds

Dharman
  • 30,962
  • 25
  • 85
  • 135
UdaWee
  • 1
  • 1