C Delete the first line from the text file without overwriting the file

I have a service that runs all the time and also stores a log file. It basically adds new lines to the log file every few seconds. I wrote a small file that reads these lines and then analyzes them for various actions. I have a question, how to delete lines that I have already analyzed from the log file without violating the log file entry by the service?

Usually, when I need to delete a line in a file, I open the source and temporary, and then just write all the lines to the temporary file, except for the original that I want to delete. Obviously, this method will not speak here.

So how can I remove them?

+5
source share
5

. , , . , .

+5

, , , , .

, , - , .

, , .

- - , .

+2

, : - char, + char , "" ( )

, , , .

0

, , .

, - / , , , / ..

0

If each line in the log has a unique identifier (or even a line number), you can simply save the identifier to which you received the parse in your logical parse. Thus, you do not need to change anything in the log file.

If the log file starts to get too large, you can switch to a new one every day (for example).

0
source

All Articles