Yosemite does not like emptying the trash

To find out what file(s) in your Trash are in use, and by whom:

lsof +D ~/.Trash

The command name in the first column will be truncated. If it's truncated so much that you cannot identify the process, the second column contains the pid (Process ID), which you can cross-reference in Activity Monitor. Or get additional info using ps -p pid.

Note:

It has been suggested that the command:

sudo rm -rf ~/.Trash

may be useful here. This is not the case!

If a file is in use (which is the scenario the question is about), it cannot be removed! Not even by root.

The suggested command may be useful if:

  • You are in an admin account (or in sudoers, which I discourage as a security weakness), and
  • The only reason you cannot remove the file is that its permissions deny deletion.

In general there are three reasons why you might not be able to empty the trash, and each reason has its own cure.

  • If the file (or folder) is locked, you can either unlock it or hold down the option key while emptying the trash.

  • If permissions do not allow you to remove the file, you can either change the permissions to allow it, or use sudo to override the file's permissions.

  • If the file is in use, your only recourse is to find the process that is using the file and make it stop using it. In the simplest case, trying again after a short wait is all it takes. It may be necessary to force quit the app, and the purpose of the lsof command is to determine which app needs to be quit. However, even root cannot remove a file that is in use.

The takeaway is that the problem "I cannot empty the trash" does not have a one-size-fits-all solution. When you are told that something is in use, do not waste time trying to apply a fix that doesn't fit that situation.

I have also seen it suggested that Secure Empty Trash may be helpful. Again, this is not the case! Secure Empty Trash will overwrite the sectors on disk that the file's data was stored in, but only after the file is successfully deleted. If you can't delete the file, for whatever reason, it won't be deleted or overwritten. If the file is hard-linked, deleting it only deletes one of its links. As long as other links remain, the underlying inode is not deleted and the file's disk space is not overwritten.


It does mean that file is in use, so removing it may affect the application which is using it. you can use lsof or fs_usage to monitor what process is using them e.g.

$ lsof -T|grep Arial
Skype       311 auniyal  txt      REG                1,4     774476  499182 /Library/Fonts/Microsoft/Arial.ttf