Author Topic: Move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir  (Read 72 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir
« on: August 04, 2025, 12:34:22 PM »
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!

Offline
****
Re: Move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir
« Reply #1 on: August 05, 2025, 02:17:38 AM »
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

Offline
*
Re: Move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir
« Reply #2 on: August 06, 2025, 12:40:11 PM »
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!


Offline
*****
Re: Move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir
« Reply #3 on: August 06, 2025, 12:43:58 PM »
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:
Code: [Select]
truncate -s0 /path/to/log

Offline
*
Re: Move NodeJS logs inside /opt/nvm/.pm2/logs to user home dir
« Reply #4 on: August 06, 2025, 02:26:14 PM »
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!