i am having issues with logrotate rotating a log file that is being constantly written to. i am using copytruncate option and it gets the job done properly on first rotation but after that, all new rotations leave a file with binary data at the top and OS shows file size bigger than before. binary data means i have missed the logs and i might be ok with that but increasing file does not make any sense.

also, when i view size using "du -ah" the sizes seem ok i.e. new files size are lower compared to the rotated ones but displaying same sizes using "ls -lh" shows increased sizes.

i think the OS still sees all of those a single file but i could be wrong.

please help me out in this matter.

thank you

closed as unclear what you're asking by HopelessN00b, mdpc, Ward, MadHatter, RolandoMySQLDBA Nov 7 '14 at 17:40

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Without the code it is impossible to answer this question – 030 Nov 5 '14 at 18:24

The program that is writing the log file has opened it write mode instead of append mode. This way, after truncation you get a sparse file with a hole at the beginning because the program keeps writing at the last position.

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