Possible Duplicate:
How can I determine what process has a file open in Linux?

Can I run a script/use a tool that monitors a file and counts the number of access that are made to it (both read and write). I am running multiple threads and trying to record the number of reads/writes that are made to the file.

marked as duplicate by Ƭᴇcʜιᴇ007, iglvzx, Journeyman Geek, slhck, Diogo Jul 21 '12 at 15:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Take a look at the strace command. Which will display or record system calls from process. For example, this will record the open, read, and write systems calls made by the command cat /etc/passwd to the file /tmp/tracelog

strace -o /tmp/tracelog -f -e trace=open,read,write cat /etc/passwd

Not the answer you're looking for? Browse other questions tagged or ask your own question.