How to monitor processes that accessed a particular file? How to monitor processes that accessed a particular file? unix unix

How to monitor processes that accessed a particular file?


you could watch to execute commands at periodic intervals. Watch also supports a differences flag for purposes of highlighting differences on consecutive runs

watch -n 5  'fuser file_name'


You could use inotifywatch, assuming you are on a Linux.

This command will print all access and modifies on a file for 60 seconds, then prints out stats.

inotifywatch -v -e access -e modify -t 60 filename

You can get inotifywatch's source as https://github.com/rvoicilas/inotify-tools/wiki