Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Sleep and wake machine to trash busy files System
I have on a number of occasions experienced files in the trash that refuse to be erased, because they are in use ... even though they are not in use. Normally that requires a machine restart.

Quite accidentally, I discovered that putting the machine to sleep and then waking it up again did the same thing. Maybe quite obvious when you think about it, but this will save me a lot of unneccesary restarts, thereby prolonging the lifespan of my CPU.

[robg adds: I'm not sure about the prolonging CPU life bit, but it will certainly save a lot of time. We've run a number of hints about deleting busy files, though none in the last year or so.]
    •    
  • Currently 2.50 / 5
  You rated: 4 / 5 (4 votes cast)
 
[5,542 views]  

Sleep and wake machine to trash busy files | 5 comments | Create New Account
Click here to return to the 'Sleep and wake machine to trash busy files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Sleep and wake machine to trash busy files
Authored by: subatomicsatan on Apr 05, '05 11:13:04AM

this comment is slightly off-topic, but relates to this hint.

is there something special about this hint? i noticed it in the rss reader i use (pulpfiction lite), but when i tried to view this hint, it stated i had to be logged in in order to see it. prior to logging in, it was invisible (on the main site). after logging in, there it is with nothing i can see that distinguishes it from any other hint. other than it is a "system" hint.

what's up with that?



[ Reply to This | # ]
Sleep and wake machine to trash busy files
Authored by: adrianm on Apr 05, '05 12:09:35PM

I get that a lot. PITA.



[ Reply to This | # ]
Terminal.app
Authored by: lullabud on Apr 05, '05 02:07:59PM
If you're comfortable with the Terminal.app there's an even quicker way to do this.

rm -r ~/.Trash/*

That's only for trash on your local disk though. Trash on other disks would need to be done with something such as...

rm -r /Volumes/FirewireDisk/.Trash/*

Be careful with that command though! It's widely known to cause big headaches (ie: important data loss) if typed wrong!

[ Reply to This | # ]
Terminal.app (and rm)
Authored by: tjfarrell on Apr 05, '05 06:05:09PM
This gets rid of the file's directory entry - but only gets rid of the actual file if nothing has it open. This may be what you want (trash will empty now), but don't expect to always get your disk space back right away. If the file is really open it is only deleted when it is closed (see "man unlink" for details) .

To work out if something has it open, you can probably use the "ls -i" command to get the inode of the file and then use "lsof" to find what has it open. For example

    > cd .Trash
    > ls -i filename
    2808535 filename
    > lsof | grep 2808535

This should tell you the name of the program with open.

(There are many other options to lsof which may help - I haven't had a good look at them, but beware that since you trashed the file, its name may have changed - I don't know if lsof reports the original file name or the current file name)

---
--
T. Farrell

[ Reply to This | # ]

Emptying stubborn trash with Terminal.app
Authored by: rpcr on Apr 06, '05 08:56:07AM

You want to put a sudo in front of both of those - the whole reason the trash won't empty is because some process has the trashed file(s) open.

An ordinary user can't override these other processes' need for the trashed file, but the superuser can.

So:

sudo rm -r ~/.Trash/*

[password requested and entered]

and/or

sudo rm -r /Volumes/MountedVolumeName/.Trashes/*

[password requested and entered]

Oh, and notice that the volume-wide trash for volumes (both mounted in the /Volumes directory, and the boot volume, /) is .Trashes, not .Trash. Only user home directories use .Trash as the trash directory.



[ Reply to This | # ]