MacOS – Finding the directory an application uses for temporary files

backupfilesystemmacos

Is there procedure or tool that can be used to find the directory in which an application stores its temporary files?

My cloud backup service reports how many files remain to be backed up. This number increases by an order of magnitude whenever I open a particular application, and decreases when I close the application. Methinks these are temp files. To prevent my backup from wasting its time indexing and uploading them, I want to exclude that application's temporary file directory. I just need to figure out where it is. Rather than rooting around in the file system like an animal, I'd prefer to use a thoughtful tool or procedure to watch where the system (or the application) is putting these temp files.

Best Answer

There are a few tools you can use to monitor file accesses but the two I'd recommend are (with their manual page descriptions):

  1. opensnoop - snoop file opens as they occur. Uses DTrace.
  2. lsof - list open files

Both are shipped with Mac OS and should do what you need. You'll need to run opensnoop in a terminal session before you start your cloud backup (it only displays changes after it's started) but lsof can display detail about all currently open files.