New in CWP Edge-LatestFree with every CWPpro licenceWebsites up to 300x faster

CWP now includes LSPHP, LSAPI-Cache and CWP Cage at no extra cost with all CWPpro licences. The LSAPI-Cache plugin is integrated into our WordPress and other script installers, and CWP Cage gives every user complete isolation. Available now in the CWP Edge-Latest version.

Get CWPpro ›

Move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir

Started by adrianofnatal, August 04, 2025, 12:34:22 PM

Previous topic - Next topic

adrianofnatal

Hi!

There is how to move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir?
Some users upload their apps with a bunch of output log lines and this cause the log files to grow and fill the entire disk space.
I was thinking that moving this logs to user's home dir will solve 2 problems:

1. If logs becomes big, they will full the user space quota and affect only your user, not all server;
2. The user can read this logs to debug or get some important information.

There is a way to do it?

Thanks!

rcschaff

You're referring to pm2, not node.   Node doesn't log anything, but the pm2 wrapper does.  Check the link below, and consider installing logrotate

https://pm2.keymetrics.io/docs/usage/log-management/
Google Hangouts:  rcschaff82@gmail.com

adrianofnatal

Hi rcschaff.

Hm, I see.

Thanks, I'll check this link.
You're right, the logs comes from pm2.
I already have linux logorotate installed (not pm2 logrotate) and running on that log files, but when disk is full it does not rotate because empty space.
Checking your link, the logrotate from pm2 has a file sizing monitoring, could be interesting.

Thanks!


overseer

I would suggest zeroing out your log files to free up disk space, then going forward implement logrotate to keep them at a manageable size:
truncate -s0 /path/to/log

adrianofnatal

Hi overseer.

Yes, I empty the logs, but the problem is no monitoring when the file grows.
I just know about the problem when the disk is full. With disk full the logrotates cannot rotate files.

I installed NodeJS versions and apps using cwp panel. In ssh I cannot run pm2 command, I cannot locate the file.

Thanks!