监视哪些进程打开了给定文件的命令

ram*_*ion 1 monitoring lsof

我知道我可以lsof path/to/file用来查看哪些进程当前打开了给定的文件。

是否有类似top的命令可以用来持续监控哪些进程打开了给定的文件?

qua*_*nta 6

看看+|-r重复模式的选项:

$ lsof -r 1 path/to/file
Run Code Online (Sandbox Code Playgroud)

您也可以使用以下watch命令:

$ watch -n 1 'lsof path/to/file'
Run Code Online (Sandbox Code Playgroud)