Emptying the trash takes "forever": is using rm -r safe to use in Mac OS X 10.7 (Lion)?

12,185

It is safe. OS X is probably just detecting the file is in use by some program, or running. If you know you really want it gone, rm it. The next reboot, whatever process was using it will be gone.

BE CAREFUL using rm -r It recursively deletes all subdirectories beneath the directory specified. If you're not familiar with shells, I'd suggest just using rm and explicitly specify files you want deleted (though you said there are lots of files).

Try this: rm -r ~/.Trash/*

That will remove all files and folders within the .Trash folder, without deleting the .Trash folder.

Share:
12,185
Eric O Lebigot
Author by

Eric O Lebigot

Director, Head of Data Sourcing in an asset management firm. Open-source programmer. Piano music composer. Board game enthusiast. Former Science Advisor in an asset management firm. Former Chief Data Scientist of a large multinational. Former head of Data Science for a startup. Former physicist (quantum mechanics, gravitational waves). Former Science & IT consultant. See LinkedIn profile. Author of the error propagation program "uncertainties", of the real time annotation program realtime_annotate and of the Markdown conversion program md_to_bgg. Have been teaching Python to graduate, doctoral and post-doctoral students, engineers and researchers since 2009. Have been loving science since 1980, and practicing it since 1998 (PhD in quantum physics). Good code design is a major priority for me. Started programming in 1983. Worked with a dozen programming languages (imperative [Python, Fortran, Perl, Pascal, BASIC, C, C++,…], functional [Caml], mathematical (Mathematica, Maple, IDL), stack-based [Postscript, HP RPL], constraint-based [Prolog], flow-based [LabView], and assembly [Motorola 68000, HP Saturn]). Have been working with Unix since 1994. Started programming in Python in 2006, and still loving it!

Updated on September 18, 2022

Comments

  • Eric O Lebigot
    Eric O Lebigot almost 2 years

    Emptying my Trash in Mac OS X 10.7 (Lion) (non securely) is taking about three hours (about 1.5 million files, from a Time Machine backup). I had to stop the process a few times already, because I could not move my laptop with the external harddrive the files are on. This is also a problem because the Trash emptying is restarted from the very beginning each time I empty the Trash again (i.e., files are not deleted when the Trash emptying is aborted).

    I read that it is faster to use rm -rf on ~/.Trash, in this case. However, is this safe? (I am afraid that does Mac OS X 10.7 (Lion) performs tasks behind the scenes—which would explain its slowness—that rm -r does not, which could lead to problems in the future.)

  • Eric O Lebigot
    Eric O Lebigot over 11 years
    Thank you. Do you have a reference about this? (Why letting the Finder empty the Trash is slower than rm, why it does not always do anything useful behind the scenes (like checking if the files are open), etc.).
  • BrenanK
    BrenanK over 11 years
    I cannot find any solid info on why, Apple Developers would probably know. I assume that when you empty the trash normally, for each file, it must check if the file is in use (locked by a process). When you have only a few files, these checks don't take too long, but when you have a large number of files, it can take awhile to do this extra check. If the trash complains that a file is in use, you can actually check it with lsof | grep filename. This will show you what process had a lock on that file. Even if it's in use, you can still remove it with rm.
  • BrenanK
    BrenanK over 11 years
    Here's some Info on Emptying the Trash by Apple: Emptying the Trash You can see some of the checks it does, some are part of UNIX (Permissions) which is what OS X is built upon, and some are part of OS X (Locking)
  • Eric O Lebigot
    Eric O Lebigot about 11 years
    I do not have "Secure Empty Trash" enabled. The problem was different, unfortunately.