How do I delete/flush pm2 logs for only one app?
Asked Answered
N

4

65

Can I flush the logs of only one app in Pm2?

Assuming my app id is 2

I tried

pm2 flush 2

but still it flushes all apps' logs.

Needs answered 14/12, 2018 at 3:1 Comment(3)
Can you open an issue on github.com/Unitech/pm2/issuesAntibody
Issue opened: github.com/Unitech/pm2/issues/4074Needs
pm2 delete all; pm2 flush - does not work ... pm2 flush; pm2 delete all - works fineGreenish
N
52

It was a bug in pm2.

I submitted an issue and they fixed it.

To solve it on your side, run these commands:

$ npm install pm2@latest -g
$ pm2 update

And it should work with the latest release.

Needs answered 20/12, 2018 at 2:33 Comment(5)
Wow! Not all heroes wear cape. Good job mate.Mongolism
well ... pm2 flush works - but it flushes ALL logs for ALL running processes. If you do pm2 flush [n] to only clear the logs for a particular id number then it says "[PM2] Logs flushed" but the logs are untouched ! Moreover, pm2 flush [n] isn't shown as an option on the PM2 cheatsheetAffiance
I'm on PM2 4.5 and it's still buggy! github.com/Unitech/pm2/issues/4074#issuecomment-694216056Contention
I'm on 5.1.2 and it doesn't work! I'm manually truncating the log files. :DFlagellate
For those who came across this problem, please take a look on https://mcmap.net/q/302607/-pm2-flush-not-clearing-logs. Good luck!Garniture
C
30

pm2 logs are located in .pm2/logs/

PM2 LOGS COMMANDS :

Show logs

pm2 logs appName|appId --lines=100

Show Error logs

pm2 logs appName|appId --err --lines=100

Empty log for specific app

pm2 flush appName|appId        

Empty all log files

pm2 flush              

Reload all logs

pm2 reloadLogs         
Ceceliacecil answered 24/9, 2021 at 11:46 Comment(0)
S
18

You can flush log of specific app by mentioning name or id.

pm2 flush my_app_name // by name
pm2 flush my_app_id   // by id
Salinasalinas answered 16/10, 2020 at 9:54 Comment(0)
L
3

Try any one of the following commands to clear the logs in pm2,

pm2 flush        
pm2 flush appName|appId
Legerdemain answered 17/11, 2022 at 3:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.