How do I append something to the end of a file when it is owned by another process?

Hello,
The script located at the following address creates the processed_logs.json file, but another process (Grafana Alloy) wants to read this file, which prevents the script from adding anything to the file:
https://pastebin.mozilla.org/cJLVLAaC

How to solve it?

Thank you.

You wait until the other process releases the file. :man_shrugging:

I don’t know how others think about externally linked sources but I personally prefer to have the script posted here - formatted as code.

1 Like

Hello,
Thank you so much for your reply.
My script is running as a service and is constantly appending new data to the end of the file. The other program needs to keep reading this file and sending the appended data to the server.

I got that. But if the other program does not give a chance for your script to write something to the transfer/input file from time to time there is no chance for you to securely update the file.

How does that actually look like? Do you get an error? If yes - share the complete error please (formatted as code).

+1 to code in the post instead of external links. Our security folks have drilled into us about clicking on unknown links.

I’ve never used pastebin before, so to me it’s an unknown link. No clicking for me :slightly_smiling_face: