Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forever logs keep growing

I run the NPM global module Forever on my Node server (on Azure). Always works fine to keep all my projects running.

There is 1 project on my server that perhaps has an issue or something that causes Forever to keep outputting to the log. There are 2 Forever logs that grow rapidly and to huge sizes:

9.7Gb  /home/azureuser/.forever/P_lf.log
1.3Gb  /home/azureuser/.forever/IEJR.log

Whilst I probably need to find out what's wrong with my project and fix it, I also need to fix this logging problem. My research shows I may need to do something with logrotate to stop this much disk space being used.

Any ideas?

like image 273
CaribouCode Avatar asked Feb 07 '23 11:02

CaribouCode


1 Answers

There are 2 moments:

  1. You can edit Your app to log only necessary things and errors (can catch errors to prevent them), so Your logs will be smaller.

  2. You can set cron job to cleanup log files every night (let's say every 03:00 AM):

    0 3 * * * truncate -s 0 /home/azureuser/.forever/*.log

    or odd days (to be able to keep logs one day for debug purposes):

    0 3 * * 1,3,5 truncate -s 0 /home/azureuser/.forever/*.log

like image 131
num8er Avatar answered Feb 15 '23 09:02

num8er