[issue44399] log rotator cookbook example might waste disk space

mori-b report at bugs.python.org
Fri Jun 11 15:59:50 EDT 2021


mori-b <moribirom at gmail.com> added the comment:

In https://docs.python.org/3/howto/logging-cookbook.html#using-a-rotator-and-namer-to-customize-log-rotation-processing, the log rotator example deletes the original log file after compressing it. However, running on Linux the command "lsof +L1" shows that the deleted original log file might still hold the same disk space, and keep growing.
Replacing the command "os.remove(source)" with "os.truncate(source,0)" seems to solve the issue by freeing the original log file disk space at each rotation.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44399>
_______________________________________


More information about the Python-bugs-list mailing list