Pm2: Should "pm2 flush" clear logs of removed processes?

Created on 30 Jul 2015  路  6Comments  路  Source: Unitech/pm2

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
Enhancement Question

Most helpful comment

It flushes only pm2.log and logs of active processes.
rm -rf ~/.pm2/logs/* would do the trick for you.

All 6 comments

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 " flush scoped logs? Because flushing is not clearing the log_file and err_file :\

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cchan picture cchan  路  3Comments

lefam picture lefam  路  3Comments

shaunwarman picture shaunwarman  路  3Comments

rajendar38 picture rajendar38  路  3Comments

liujb picture liujb  路  3Comments