1

I know I can use lsof path/to/file to see which processes currently have a given file open.

Is there a top-like command I can use to continuously monitor which processes have a given file open?

rampion
  • 268
  • 1
  • 6

2 Answers2

6

Take a look the +|-r option for repeat mode:

$ lsof -r 1 path/to/file

You can also use the watch command:

$ watch -n 1 'lsof path/to/file'
quanta
  • 50,327
  • 19
  • 152
  • 213
3

Instead of lsof, I would suggest using fuser(1), especially since you say you want to watch for processes, and not ports or users or anything else.

adaptr
  • 16,479
  • 21
  • 33