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.

When you try to empty the Trash in OS X, and there is a file still open in an application, you receive the dialog:

enter image description here

The operation can't be completed because the item "…" is in use.

How can I find out which application or which process still uses this file?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Using lsof to find what's keeping the file open

Open up Terminal.app and use the following command to get to your Trash:

cd ~/.Trash

Now, enter the following command:

lsof name-of-file

For example, in the above screenshot, it would be: lsof pdf\ 08-53-59.pdf (important to escape spaces here). You can also just enter lsof with a space afterwards, and then drag the file from Finder's Trash into the Terminal window.

enter image description here

The command will output something like the following:

charon:.Trash werner$ lsof pdf\ 08-53-39.pdf 
COMMAND  PID   USER   FD   TYPE DEVICE  SIZE/OFF     NODE NAME
Finder  5022 werner  txt    REG   14,2 636141715 32494023 pdf 08-53-39.pdf

In that case, we know that Finder is keeping the file open. For any other application, it would be easy to just activate and quit it. In case of the Finder, there's no obvious "quit" button.

To kill the Finder and release the document, just enter the following in the Terminal:

killall Finder

You should now be able to empty your Trash.

Other tricks

If the above does not succeed, here are some very basic tricks you can try to empty your trash:

  • Log out from your user, and log in again
  • Reboot the Mac, log in again
share|improve this answer
2  
Note that if the file is being used by a system process (not a user program), you'll need to use sudo lsof name-of-file (and then enter your password to authenticate as an admin) to see what's using the file. If it's a system process using the file, it's generally safest to reboot rather than trying to quit the program (that's not always safe...) –  Gordon Davisson Nov 30 '11 at 17:52

lsof didn't return anything for me even with sudo. But simple rm did the trick.

cd ~/.Trash

In my case it was app so:

rm -rf some.app
share|improve this answer
    
It's lsof not lsoft. And +1, since Mac OS is of course Unix based, I was a bit surprised to see that files in use get locked by the OS, but good ole trusty Unix-based rm would surely do the trick! :) –  jmort253 Dec 18 '12 at 8:29
    
Thanks, fixed the typo. –  Unknown_Guy Dec 18 '12 at 8:48

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.