Is there an efficient way to replace the last line from a file?
I need this for log files, to have this kind of line:
21:00:00 - Info - Count: 3
Be replaced with this:
21:00:35 - Info - Count: 4
And so on.. So it looks cool in a tail -f
The problem is that log files can get really big, and I don't want them being loaded into the memory everytime I want to replace the last line.
Anyway, if loading the whole file was the only way, how would you go about it, having in mind that there are other scripts appending data to the same file, simultaneously? I guess I have to lock it or something. I never used that because I just use file_put_contents with the FILE_APPEND option.