Trying to find out what changing the maximum possible CPU frequency when on battery power I realized that what I need is a tool that can monitor access to a particular file and log the PID of process that is making that access. It should work on virtual FS such as proc, otherwise it wouldn't be useful to me.

link|improve this question

68% accept rate
feedback

2 Answers

up vote 4 down vote accepted

Commands from the audit or the inotify-tools package can track file access. See my answer to a very similar question: Unix - Historically who all opened a particular file. Most answers on that question answer your question. I'd have considered this a dupe, but the OP seems to have had a different requirement in mind in asking that question.

Update: These commands might not work as you expect on /sys as it's a pseudo-filesystem.

link|improve this answer
It works, thanks :) – vava Sep 5 '09 at 15:24
feedback

lsof is what you are looking for.

link|improve this answer
Not really, as a file I want to track access to is small, writing to it takes few milliseconds. I'm not sure lsof in repeat mode can catch it but I'll give it a try. – vava Sep 5 '09 at 14:51
feedback

Your Answer

 
or
required, but never shown

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