File detection is closed
Is there an easy way to detect when a file is closed for writing? I have a process that gives out a new file every 5 seconds. I cannot change the code for this process. I am writing another process to parse the contents of each file immediately after it is created. Is there an easy way to view a specific directory to see when the file is no longer open for writing? I am hoping for some Linux command.
+2
a source to share
5 answers
Since you are using Linux as your platform, you may need to look at the inotify system calls. When tracing a directory the output files were written, you will get open / closed events for the files created there.
If you want to integrate this into a shell script take a look at inotifywait which is part of the inotify tools.
+2
a source to share