Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Let's say, I would like to figure out what pip install does, like what files are downloaded, where are they extracted, where is the temporary files, ...

Are there any suggested way to track the opened files by script under Linux?

share|improve this question

2 Answers 2

I think you're looking for Inotify. It tracks down changes to files and directories under a given path. And there are lot of options to make it work like you want. And also, this is not process dependent, so you get any changes made by any process or script.

You can also have a look at fschange, which uses inotify as backend.

And if you want a GUI tool, check out DaemonFS.

share|improve this answer
    
Using inotify, is there any way to determine which files were modified by which programs? –  Anderson Green Dec 29 '12 at 1:51

You could use the "lsof" command to get a list of open files, for a process with a particular pid. Here's a useful introduction: http://www.akadia.com/services/lsof_intro.html

To get the process id of the command, you could do something like ps ax | grep pip. Then just pass that to lsof like so: lsof -p theprocessid

share|improve this answer
    
Then, my next question is how to get that process id asap cause the script is running so fast. Furthermore, because it's a script, some file accessing is done by other programs/scripts instead! –  Drake Jan 28 '12 at 10:22
1  
In that case, a better approach may be to use strace, combined with the -f option to "follow" child processes. You're going to get a lot more output though :) You can just run it like strace -f pip install. Or what Bibhas said :) –  Penny Leach Jan 28 '12 at 11:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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