Cannot empty Trash in macOS: Trash can’t be opened right now because it’s being used by another task
I am trying to empty my trash, and it keeps giving me the error message:
“Trash” can’t be opened right now because it’s being used by another task, such as moving or copying an item or emptying the Trash. Try again when the current task is complete.
Skip Stop Continue
I have tried restarting my computer and running Finder
> Secure Empty Trash
. Everything yields the same result and error message from above.
Solution 1:
Try running this command in Terminal:
sudo rm -rf ~/.Trash/*
It should prompt you for your administrator password, but that should remove any files in the trash without any issues.
Good luck!
Solution 2:
You can use fuser
to list the processes that have an open file:
ps -eal | grep $(fuser ~/.Trash)
Solution 3:
X LAB
...has a guide for troubleshooting trash problems in Mac OS X.
Files in use by other applications
Use one or more of the following methods if you receive a message indicating that a file can neither be moved to the Trash, nor emptied from the Trash, because it is "in use" by another application.
Quit the application that is using the file. This will usually permit
you to then move the file to the Trash or to empty the Trash. If you are
unsure of the application that has the file "in use", the Terminal
command lsof
can tell you the name of the process or application that
Mac OS X considers to be using the file, as follows:
Click the Trash icon in the Dock to open a Finder window showing the contents of your Trash.
Open Terminal.
At the Terminal prompt type
lsof
followed by a single space, but do not press Return yet.-
Drag and drop the file "in use" from the Trash to the Terminal window. The path to the file will appear after the
lsof
command:lsof /path_to_file
Press Return. If the file is "in use" then the output from lsof will list the names of the applications or processes which claim to be using the file under the first column heading, COMMAND.
If the file is "in use" by an open application, Quit that application. If a background process has the file "in use," use Activity Monitor to terminate that process.
Note: One must be careful when terminating processes as certain background processes are needed for Mac OS X. Quitting processes like loginwindow or kernel_task could force you off your account, freeze your Mac, or cause a kernel panic. If you do not know what effect quitting a process may have, do not quit the process.
Empty and recreate an account's Trash
-
Affected account is admin:
sudo rm -ri ~/.Trash
-
Affected account is user:
sudo rm -ri /Users/user_name/.Trash
Then log out and back in.
Note: Assure you have typed the command exactly as specified before proceeding as typographical errors in this command can have dire consequences!
Solution 4:
To identify which task is using your Trash, you can use the following command:
lsof | grep Trash
then quit or kill it by specifying PID from the second column, e.g.
kill PID
Add -9
to forcibly kill it.
Alternatively you can install What's Keeping Me application which can identify and kill the processes which are blocking your Trash from being emtied.
As per site brief:
Have you ever have the problem where you can’t empty the Trash or eject a disk because something is preventing you? Usually the reason is because some application has a file open, and thus you can’t get rid of the disk or trash the file. That’s why we made What’s Keeping Me! What’s Keeping Me will identify the application that is holding the item open.
Solution 5:
Trash It! (free)
This AppleScript Application force-empties your Trash. Especially useful if you have files or folders in the Trash with permissions set incorrectly, locked Trash items, want to securely delete a stuck item, or trash items from other partitions.