-1

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

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

1 Answer 1

3

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 .