Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to monitor processes that accessed a particular file?

i know there's a fuser command that lists out pids of processes, but how do you continuously monitor what process accessed the file? (think behavior similar to tail -f filename)

say there's a process which writes to a file and releases the handle at some interval, so it's hard to catch that process using fuser.

like image 852
the1plummie Avatar asked Jul 21 '12 01:07

the1plummie


People also ask

How do you find which processes are using a particular file?

Lsof is used on a file system to identify who is using any files on that file system. You can run lsof command on Linux filesystem and the output identifies the owner and process information for processes using the file as shown in the following output.

How do I monitor a file access in Windows?

Navigate to Computer Configuration -> Windows Settings -> Security Settings ->Local Policies -> Audit Policy. Under Audit Policy, select 'Audit object access' and turn auditing on for both success and failure.


1 Answers

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'
like image 190
iruvar Avatar answered Oct 02 '22 01:10

iruvar