1

I am using Debian running on a BeableBone Black with 4GB of internal flash storage.

My program is continuously writing / appending to a log file that I created with >> every minute, all day everyday .

Is there a limit to the size of this file? Will this file be continuously written to until there is no more memory left, and what would happen then?

How can I make the file circular, so that it starts to write from the beginning again after a few days?

4

Is there a limit to the size of this file?

Not unless the file system imposes a limit. On a 4GB flash with a modern file system the answer is, you will run out of space a long before you hit the maximum file size. So no, there's no limit.

Will this file be continuously written to until there is no more memory left

Yes

what would happen then?

Your program will fail to write to the file. Every program on your system will fail to write any file on that file system. That failure will cause many programs to fall over silently (they won't be able to log why they fell over because there's no space to the log).

It's really bad and usually requires you to clear some space and then reboot before everything works again.

Some people recommend that you keep /var/log on it's own partition to ensure your logging can't kill your system.

How can I make the file circular, so that it starts to write from the beginning again after a few days?

This is the subject of "log rotation". Fortunately Debian comes shipped with a log rotation tool built in. I recommend reading the manual for logrotate. This tool will periodically move the log file and start a new one. It will also automatically compress and eventually delete old log files so you don't run out of space. All you need to do is add a configuration file for your program to /etc/logrotate.d/.

Note: If your program never closes the log file then you might need to use the copytruncate setting in your configuration file. But only use this if you need to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.