Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Where do log files locate in pm2 in sudo mode

I’m new to PM2 and ubuntu-related issues.

I’m running an app using sudo with the syntax sudo pm2 start app.js --time.

However, when I tried to check the files in $HOME/.pm2/logs/app-error.log, I couldn’t find any logs related to what I logged in the code. I believe sudo pm2 start is different from pm2 start, and the log files are only for the pm2 start.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My question is, how can I check the logs in sudo pm2?

>Solution :

If you execute pm2 as the root user, the logs will be stored in /root/.pm2/logs/.

sudo executes commands as the root user, and that also entails that the home directory (referred to as $HOME or ~) that the command sees is the root user’s home directory, which usually is /root.

So, if a program writes logs to the user’s home directory, the location of the log files will depend on what user is executing that program.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading