See which process uses the file in Mac OS X

I would like to be able to track the file and see which process relates to this file. Is it possible? I know that I see a list of open processes in the activity monitor, but I think this happens quickly so that I can see it. The reason for this is because I use the framework, and I think that instead of the debug version, the system version of the framework is used, and I would like to see what process it is about.

+72
unix terminal audit macos lsof
Nov 29 '11 at 20:19
source share
5 answers

lsof will display open files, but it may be a little inconvenient for short-term touches (for example, if the file is not open when lsof is running, it does not appear).

I think fernLightning fseventer.app would be the best choice. This is "nagware" and allows you to watch (graphically) the fsevents API in real time.

+71
Nov 29 '11 at 20:38
source share

It is simple: sudo fs_usage | grep [path_to_file] sudo fs_usage | grep [path_to_file]

+64
Nov 30 '11 at 1:08
source share

But I spent 2 minutes googling and found your answer here .

$ lsof | grep [whatever]

Where [independently] is replaced by the name of the file you are looking for. With this, you can see which program is desperately holding an about-to-be-trashed file. When you exit this program, your garbage will be empty.

+34
Nov 29 '11 at 20:26
source share

Faster way:

 $ lsof [path_to_file] 

This solution does not require a root password and returns the following clear result:

 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Finder 497 JR7 21r REG 1,2 246223 33241712 image.jpg QuickLook 1007 JR7 txt REG 1,2 246223 33241712 image.jpg 
+8
Nov 01 '13 at 8:40
source share

Another option is Sloth . This is the free open source GUI for the LSOF that others have talked about.

+8
Dec 07 '13 at 7:23
source share



All Articles