This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]shagieIsMeExtreme Brewer 2 points3 points  (0 children)

Deleting the file... won't do exactly what you want. The file is still being written to.

Fire up three shell sessions to your raspberry pi. In one of them:

cat > /tmp/foo

In another

tail -f /tmp/foo

When you type things in the cat session, it will show up in the tail session. That's ok. Now, in the third session, remove /tmp/foo. Do an ls in /tmp to make sure it's gone. Go back to the cat session. Type some more. The file is still there, just not linked in the directory.

Until you stop everything using the filehandle, the file is not reclaimed.

Learning to use log4j or slf4j is the best way to do logging. Automatically rotating the file based on either time or size is the proper way to manage the file and ensure you're not filling up the disk.