I start a nodejs app using pm2, the log out-file config setting is default.
Now, i find the log is too huge, so i need to redirect the log to /dev/null
without restarting the process and without using pm2 -logrotate
.
Is there any way around this issue?
You will have to restart the process if you want a fresh redirection. If restarting is okay, then it could be like:
pm2 'command' > /dev/null
If not, then you can possibly write a very basic shell script and schedule it via cron. It would just clean your logs (pm2 flush
), or compress and dump (whichever you prefer).