Reputation: 1197
How do I clean logs for foreverjs for a running process? I can manually delete the log files but that results in forever not logging anymore.
I've also seen cleanlogs but that only removes historical logs, but not affecting logs of any active processes.
Upvotes: 6
Views: 9822
Reputation: 1219
I needed this just now and this was my solution:
➜ ~ forever list
info: Forever processes running
data: uid command script forever pid id logfile uptime
data: [0] n8Hy /root/.nvm/versions/node/v8.11.4/bin/node app.js --genesis node.json --config config.json 1941 1955 /root/.forever/n8Hy.log 30:16:11:52.822
➜ ~ echo "deleted..." > /root/.forever/n8Hy.log
This will basically overwrite the whole log file with the text "deleted...", of course you can just overwrite it with an empty string.
note that >> will append a line to a file, but > will just delete everything and add a line to a file.
Upvotes: 2
Reputation: 163
You can:
$ forever list
Copy log path.
Using VIM:
Select all and delete (actually move to buffer)
:%d
Then save file
:x
Upvotes: 0
Reputation: 470
Steps to be followed to clear single log file:
Steps to be followed to clear all log file:
Upvotes: 0
Reputation: 29172
If Linux, may be some like this help:
for i in /var/forever/path/to/log/*; do cat /dev/null > $i; done
Upvotes: 3
Reputation: 1313
From the forever documentation:
forever cleanlogs [CAREFUL] Deletes all historical forever log files
Upvotes: 13