Checking if a file is open
by madhatt30 from LinuxQuestions.org on (#6MK44)
Scenario:
I have multiple computers networked together with one of them being the host (server). The server has a share setup that all the other computers create files and write too (simple enough). For simplicity sake let's call the server, server and the other computers comp1, comp2 and comp3 etc.
The server checks the share every 15 minutes querying the files which are text files and scrubs them. The files from comp1 comp2, and comp3 stay open from anywhere between 1 hr 1.5 hrs (encryption and decryption). During the server check on the files I need to reliable determine if the file is still open and if it is don't do anything with it and if it isn't then we are clear to process the file; yes the files do remain open and written to the whole time. The files are never closed until the process is completed.
Question:
What would be the best way to approach the detection of an open file like this?
Side quest Question: will 'lsof' be able to tell me if the file is still open, even if it is on the share and created and written to by another computer?
Thank you all in advance for any insight!
I have multiple computers networked together with one of them being the host (server). The server has a share setup that all the other computers create files and write too (simple enough). For simplicity sake let's call the server, server and the other computers comp1, comp2 and comp3 etc.
The server checks the share every 15 minutes querying the files which are text files and scrubs them. The files from comp1 comp2, and comp3 stay open from anywhere between 1 hr 1.5 hrs (encryption and decryption). During the server check on the files I need to reliable determine if the file is still open and if it is don't do anything with it and if it isn't then we are clear to process the file; yes the files do remain open and written to the whole time. The files are never closed until the process is completed.
Question:
What would be the best way to approach the detection of an open file like this?
Side quest Question: will 'lsof' be able to tell me if the file is still open, even if it is on the share and created and written to by another computer?
Thank you all in advance for any insight!