One of the things I forgot when I wrote the PM2 post is that PM2 creates logs. And these logs get very big, very fast!!

The pm2-logrotate takes care of this.

To install pm2-logrotate

$> pm2 install pm2-logrotate

The defaults work perfectly fine. It will retain logs for 30 days and rotate the log every day, each with a max-size of 10 MB.

To change any of these settings –

$> pm2 set pm2-logrotate:max_size 1K (1KB)
$> pm2 set pm2-logrotate:compress true (compress logs when rotated)
$> pm2 set pm2-logrotate:rotateInterval '*/1 * * * *' (force rotate every minute)