From docs:
$ pm2 flush # Clear all the logs
Now it works as follows:
pm2 start app.js // console.log('Log')
pm2 delete all
pm2 flush
pm2 start app.js // console.log('Log')
pm2 logs // output two "Log" messages
It flushes only pm2.log and logs of active processes.
rm -rf ~/.pm2/logs/* would do the trick for you.
How can I have "pm2 flush" or "pm2 flush
would be great to have option pm2 logs flush all
If I run rm -rf ~/.pm2/logs/* then log files are not recreated if the process is not restarted
what I would expect from pm2 logs flush all is:
delete files from inactive processes and truncate files from active processes.
Also would be great to have some option to show what's max file size and/or how many days back, logs should be saved.
@liesislukas There is a module that handle file rotation if you want : https://github.com/pm2-hive/pm2-logrotate
Currently i use this to restart the process completely fresh!
export DIR=`eval echo ~$USER/.pm2`
if [ -d "$DIR" ]; then
sudo chmod -R 777 "$DIR"
rm -R $DIR
fi
Same can be done only for logs
Hi there. Any idea on how to clear the log of a specific process alone. pm2 flush clears log of all processes running. I want to clear the log of only one process (Ofcourse I can go to the file and manually clear it) - anything native from pm2?
Most helpful comment
It flushes only pm2.log and logs of active processes.
rm -rf ~/.pm2/logs/*would do the trick for you.