pm2 logs can grow big overtime. As big as 50GB or more in a month time based on your application usage. Eventually you may run out of disk space. Here are the simple steps to manage it.
features. This should take care of auto rotating, compressing and managing logs.
sudo pm2 install pm2-logrotate
If you get an error saying pm2: command not found, then install pm2 using the command
sudo npm i -g pm2
Additional step: If you want to make sure the pm2-logrotate makes use of native logrorate, then run the command
sudo pm2 logrotate -u your-server-username .
To make sure the native logrotate is working fine, run the command:
logrotate -f /etc/logrotate.d/pm2-your-server-username
While this will show empty output and return to command prompt, you will be able to see certain log files compressed (.gz files) at the usual logs folder location of pm2, that is at ~/.pm2/logs