开发者

How to detect, if any other entity/process is writing a file, in Linux?

开发者 https://www.devze.com 2023-04-12 04:38 出处:网络
Please note that, I don\'t have any control over the target file. Some other process is writing that file. I just want to copy the file when other process completes the write operation.

Please note that, I don't have any control over the target file. Some other process is writing that file. I just want to copy the file when other process completes the write operation. I was wondering, how i can check the writ开发者_开发知识库e operation on a file ?

Thanks !


Try F_NOTIFY argument to fcntl.

Or you can try inotify if you know that you have a Linux kernel >= 2.6.13. I found an article in Linux Journal which describes how to use it.


You can use the lsof command, as follow, for example:

lsof | grep myfile
0

精彩评论

暂无评论...
验证码 换一张
取 消